-->
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.  [ 3 posts ] 
Author Message
 Post subject: Cascade delete
PostPosted: Fri Mar 30, 2007 1:01 pm 
Newbie

Joined: Fri Feb 09, 2007 11:06 am
Posts: 3
Hi, i have a one-to-many relation in which the parent has a bag of children with cascade="all".

Supposing that i have a parent object "parentObj", when i call session.Delete(parentObj) it is supposed to delete all childs too?

That's what i think that makes sense, but when i try to do this, i get a "The DELETE statement conflicted with the REFERENCE constraint" exception.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 02, 2007 12:38 pm 
Newbie

Joined: Mon Apr 02, 2007 12:31 pm
Posts: 19
Is cascade="delete" specified in the many-to-one mapping from the children to the parent? This thread says that cascades apply to the other side of the association.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 02, 2007 12:52 pm 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Can you post the code between the session open and close that throws this exception? If you are doing a bidrectional association you'll not only need to do a parentObj.Children.Remove(childObj) but also a childObj.Parent =null. Be sure, too, that you have inverse="true" in the appropriate place.

MIKE

_________________
If this helped...please remember to rate it!


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