-->
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: Strange Orphan Behavior: Assign Child to Another Parent
PostPosted: Mon Feb 15, 2010 8:20 am 
Newbie

Joined: Wed Sep 02, 2009 11:53 am
Posts: 5
Hi

I have a one-to-many association between the classes Parent and Child. The mapping sets the cascading action to all-delete-orphans, to delete the Children which don't have a Parent anymore.

But, this setting also deletes the Children which are assigned to a different parent: I remove the Child from its Parent's collection, add it to the collection of the new Parent, and finally set the Parent property of the Child to its new parent. When flushing the session, the cascade mechanism detects that the Child has been removed from its first Parent's collection, and tries to delete it since it considers it as an orphan.

However, the Child is not an orphan, it just has been adopted by another Parent.

Is that intended NHibernate behavior, or am I missing something?

Thank you!
Jonas


Top
 Profile  
 
 Post subject: Re: Strange Orphan Behavior: Assign Child to Another Parent
PostPosted: Thu Feb 25, 2010 3:47 pm 
Beginner
Beginner

Joined: Tue Aug 25, 2009 11:42 am
Posts: 49
After the child is removed, "detach/evict" it from the session and then add it to a different parent. And if u are relying on cascading, update the new adoptive parent.


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.