Java : Java related items, personal opinions, coding, etc.
Updated: 3/9/2004; 3:43:18 PM.

 

Subscribe to "Java" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Tuesday, March 09, 2004

I'm going to start by saying that I may have missed something somewhere in the Hibernate documentation, FAQs, or forums.  But, I don't remember seeing direct references to this.

It seems that is a bad idea to make both ends of an inverse mapping cascade.  In this situation, Hibernate will try to cascade multiple times when saving new objects that cause a cascade.  The only way I found to prevent it was to remove the cascade attribute on the inverse end of the mapping.

OK, a little less talk and a little more coding please.  I had something like this and it was bad:

  <!-- Application class -->
  <class name="net.trin.colorreports.reportcomments.dao.valueobjects.Application">
    <id name="id" column="application_id" type="integer">
      <generator class="identity">
      </generator>
    </id>
    <property name="name" type="string" column="application_name">
    </property>
    
    <set name="reports" inverse="true" lazy="false" cascade="all">
     <key column="application_id"/>
     <one-to-many class="net.trin.colorreports.reportcomments.dao.valueobjects.Report" />
    </set>
  </class>
  
  <!-- Report class -->
  <class name="net.trin.colorreports.reportcomments.dao.valueobjects.Report">
   <id name="id" column="report_id" type="integer">
    <generator class="identity"/>
   </id> 
   
   <property name="name" type="string" column="name"/>
   
   <many-to-one name="application" column="application_id" class="net.trin.colorreports.reportcomments.dao.valueobjects.Application" cascade="save-update" />
   
   <set name="comments" inverse="true" lazy="false" cascade="all">
    <key column="comment_id"/>
    <one-to-many class="net.trin.colorreports.reportcomments.dao.valueobjects.SummaryComment" />
   </set>
  </class>

Notice the cascade attributes on the <set> tags.  This created the loop because of the cascade on the <many-to-one> tag I think.  Once I removed the cascade attribute from the <set> tags, everything started working beautifully.


3:43:15 PM    comment []

I hope that someone smarter than I am will read this and correct me.  It seems that if I name a directory "tags" somewhere in my CVS project, it will not be handled correctly by IBM Websphere Studio 5.1.1 (Eclipse 2.1.2).  When I try to check that directory (a Java package directory) out of CVS, WSAD says "error fetching file revisions". 

I am using CVS for NT, but I AM NOT using a repository prefix.  So, I don't have this known error situation.  I'm not sure if my issue is a WSAD/Eclipse issue, a CVS for NT issue, or just a CVS issue. 

We are working around it by renaming our tags package to taglib.


3:23:36 PM    comment []

© Copyright 2004 Tom Pierce.



Click here to visit the Radio UserLand website.

 


March 2004
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Feb   Apr

Search

 
How this works

Emacs Sources
 tsql-indent.el
 user-add-sql-folding-marks
 remove-line-boundary-in-region
 convert-camel-to-underscore

My Subscriptions
 Funny
 KM