-->
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.  [ 1 post ] 
Author Message
 Post subject: Need help in hibernate collection mapping
PostPosted: Wed Jun 11, 2008 8:09 am 
Newbie

Joined: Thu Feb 28, 2008 12:35 pm
Posts: 15
Hi all,

I have a query regarding the saving mapped object in hibernate.

I have this mapping in my application

Entity A hbm contents
---------------------------------
<set name="bContents" table="B" lazy="true" inverse="true" cascade="all-delete-orphan" sort="unsorted" >
<key column="B_ID"></key>
<one-to-many class="com.xyz.B"/>
</set>

Entity B hbm contents
---------------------------------
<many-to-one name="a" class="com.xyz.A" cascade="none"
outer-join="auto" update="true" insert="true" column="A_ID" not-null="true"/>

<set name="cContents" table="C" lazy="true" inverse="true" cascade="all-delete-orphan" sort="unsorted">
<key column="B_ID"></key>
<one-to-many class="com.xyz.C"/>
</set>

Entity C hbm contents
---------------------------------
<many-to-one name="b" class="com.xyz.B" cascade="none" outer-join="auto" update="true" insert="true"
column="B_ID" not-null="true"/>

Currrently, in my application each of these entities are saved seperately. We are not saving the relationships while saving the contents like
A a = getA();
B b = new B();
save(b)
a.getBContents().add(b); // This is not done
save(a);// This is not done

I am not sure why we are getting inconsistent entries in collections above bContents and cContents when we load the object a or b.

Can somebody tell me whats da best practice to save such mapped relationships.??

Thanks in advance,


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

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.