-->
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: How to change a child's parent?
PostPosted: Mon Aug 29, 2005 7:33 pm 
Newbie

Joined: Tue May 10, 2005 1:16 pm
Posts: 16
Location: Vancouver, BC, Canada
Easy question:

Standard Parent/Child relationship, indexed, cascade="all-delete-orphan".

I want to move child C from having parent A to parent B.

I do

Code:
A.getChildren().remove(C);
C.setParent(B);
B.addChild(C);


and everything is fine for the rest of the session.

But, after the session is flushed I find that A has been deleted. I guess this is because "delete-orphan" is doing it's job. Strangely I get no error about C now being in the B.getChildren() collection, and it just disappears from it, with no FK violation.

How does one change a child's parent?

Do I have to turn off "delete-orphan" and manage deletion myself?

_________________
http://www.JamesAshepherd.com/


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.