-->
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: Delete-Orphan on One-to-Many relationship -> Why merge?
PostPosted: Fri Sep 26, 2008 11:01 am 
Newbie

Joined: Fri Sep 26, 2008 10:48 am
Posts: 10
Hello!

I'm using Hibernate Annotation @Cascade(CascadeType.DELETE_ORPHAN) in addition to my JPA cascading annotations.

If I try to save a detached instance of the parent object whose children have been modified/deleted, update() only sets the foreign key of the children to 'null'.
Why are orphans only deleted when I use merge()??

Does this indicate that there might be a session that has already been opened? As far as I understood, update() should be used when a session is fresh.

I'm a little bit confused. Maybe there is someone who can give an explanation.


Hibernate Version: 3.2.6.ga


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2008 12:04 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
In your design, can children exist as independent entities, without a parent?

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2008 1:46 pm 
Newbie

Joined: Fri Sep 26, 2008 10:48 am
Posts: 10
No they can't.


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.