-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Mapping list persistence problem
PostPosted: Tue Jul 05, 2005 12:43 pm 
Newbie

Joined: Tue Jul 05, 2005 11:56 am
Posts: 2
On page 213 of Hibernate In Action is an example of what the we’re trying to do. However it doesn’t talk about actually persisting any changes to the database.

I have debugged my application and have found that an INSERT into CHILD_TABLE is not happening when an INSERT into PARENT_TABLE occurs.

Also, when an PARENT_TABLE UPDATE is done, a database referential integrity error is thrown when a Hibernate remove ParentBeans is executed because it’s not deleting the rows in CHILD_TABLE first.

Here’s the mapping file:
<hibernate-mapping>
<class name="ParentBean" table="PARENT_TABLE" >
<composite-id>

<key-many-to-one name="storeGoalBean" class="StoreGoalBean" column="ID_STR_RT" access="field" />

<key-many-to-one name="employeeBean" class="EmployeeBean" column="ID_EM" access="field" />

</composite-id>

<version name="version" column="VERSION" unsaved-value="negative" type="integer" access="field" />

<property name /> <-- bunch of properties here -->
.
.
.

<list name="changeDates" inverse="true" table="CHILD_TABLE" access="field" cascade="all-delete-orphan">
<key>
<column name="ID_STR_RT" />
<column name="ID_EM" />
</key>
<index column="SEQ_NUM" />
<element type="timestamp" column="CHANGE_DATE" not-null="false" />

</list>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 1:09 pm 
Newbie

Joined: Tue Jul 05, 2005 11:56 am
Posts: 2
To fix the problem I removed inverse="true" and added lazy="true"

<list name="changeDates" lazy="true" table="CHILD_TABLE" access="field" cascade="all-delete-orphan">


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.