-->
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: Unassociating relations when deleting an entity
PostPosted: Fri Oct 20, 2006 2:33 pm 
Newbie

Joined: Sat Mar 11, 2006 4:15 pm
Posts: 15
So lets say you have Entities A and B with @ManyToMany relation on both sites with A being the owning side of the relation. Now lets assume that I delete a B that is associated with an A this gives me a foreign key error because now I have A still refering to a B that doesn't exist. What I would like is to have B removed from A's collection of B's when it is deleted. Is there any way to do this at the hibernate level or is this strictly something that the application has to take care of manually? Thanks. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 21, 2006 5:35 am 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Specify cascade="delete" on the collection thats mapping A's from B. That way, when you delete B, it cascades to the associations that it has and will remove entries from the association table as well.


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.