-->
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.  [ 4 posts ] 
Author Message
 Post subject: Parent - Child Cascade Updation
PostPosted: Sun Nov 02, 2003 4:41 pm 
Newbie

Joined: Thu Oct 30, 2003 6:41 pm
Posts: 4
I have a parent class(CONTRACT) which has one to many relation with the child class(SPLIT).
In the parent .hbm.xml i have defined the following relationship...

<bag name="_splitsList" cascade="all">
<key column="CONTRACT_ID"/>
<one-to-many class="com.bunge.bgm.contract.business.domain.trade.Split"/>
</bag>

and in the child class i ahve defined


<id name="_id" column="SPLIT_ID" type="integer" unsaved-value="any">
<generator class="sequence">
<param name="sequence">T_SPLIT_SEQUENCE</param>
</generator>
</id>
<many-to-one name="_contract" column="CONTRACT_ID" not-null="true"/>

Now when i am trying to insert the data. Everything works proper. Data is inserted into the Parent as well as the child tables.
However when i try to update the parent by calling update(parent object) ...which in turn should update the child(ren)...whats happening is the parent is updated, but new records are inserted into the child table. Any ideas why?

Thanx & Regards.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 6:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Thats what unsaved-value="any" does.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 6:53 pm 
Newbie

Joined: Thu Oct 30, 2003 6:41 pm
Posts: 4
gavin wrote:
Thats what unsaved-value="any" does.


I tried putting unsaved-value="null". But then this was creating a problem during creation and child records(SPLITS) were not being inserted into the child tables


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 02, 2003 6:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Perhaps you need unsaved-value="0", or something. Have you read the documentation??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.