-->
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: Hibernate Parent Child Relationship
PostPosted: Thu Nov 03, 2011 6:28 am 
Newbie

Joined: Thu Sep 22, 2011 11:58 pm
Posts: 3
Hi,

I have a parent table Parent which has many to many mapping with the Child table and I also have the Parent_Child table that stores the parent_id and child_id following is the hibernate mapping defined.

<class name="Parent" table="Parent">
<id name="Parent_id" type="long">
<column name="Parent_id">
</id>
<set inverse="true" table="Parent_Child" cascade="save-update">
<key>
<column name="Parent_id"/>
</key>
<many-to-many entity-name="Child">
<column name="Child_id"/>
</many-to-many>
</set>

When I save the parent it inserts the record into the parent table and child table but does not store anything in the Parent_Child table. I want records to be inserted in the parent,child and parent_child table. What is the best way to do so in hibernate.

Thanks,
Bkhe


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.