-->
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: Many-to-many and update/delete
PostPosted: Wed Feb 02, 2011 9:36 pm 
Newbie

Joined: Tue Feb 01, 2011 8:17 pm
Posts: 7
Hi,

I would like to know how configure hibernate to update properly a collection list.
I explain my simple case :
I have 2 entities Journey and Segment. Entity Journey have a list of segment. But 2 Journey can share the same Segment, it's why i have a many to many.
My problem is when i update Journey with a new list of Segment, Hibernate delete the entry of the link table but dont delete the segment useless. Why ?

Other question, if i have 2 Journey and i delete one of them , can i configure hibernate to just delete the segment linked ONLY with this journey ?
Because if a segment is linked to an other journey i want to keep it ....

Thanks


Top
 Profile  
 
 Post subject: Re: Many-to-many and update/delete
PostPosted: Wed Feb 02, 2011 9:47 pm 
Newbie

Joined: Tue Feb 01, 2011 8:17 pm
Posts: 7
I found the anwser to my first question :
delete: automatically delete the referenced object(s) when delete() is called on the referencing object. Note that, if the referencing object is not deleted but merely removes its reference to the referenced object, then this option will not do anything and, potentially, a garbage (or orphan) object will be left in the database

But how can i maintain properly my table of child if nothing clean it ?
I am oblige to fetch all the child and if the id of the child don't have entry in the link table i delete it ?

Thanks


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.