-->
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: delete-orphan does not work
PostPosted: Fri Dec 02, 2005 3:04 pm 
Newbie

Joined: Fri Dec 02, 2005 2:48 pm
Posts: 13
Hibernate Version: 3.0.5

I have a bidirectional one-to-many association (Parent <-> *Child) and I want the Child be deleted when the Child has no reference to the Parent (Child table has a null value in column 'PARENT_IT'), by saving (using saveOrUpdate method) the Parent with an empty set of Child.

I tried to use 'all-delete-orphan', but it does not work when using saveOrUpdate method.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 03, 2005 4:14 pm 
Newbie

Joined: Sat Nov 19, 2005 10:10 pm
Posts: 9
You didn't say much about how you exactly do it.

May be it is interesting for you, there is a bug in JIRA probably around your issue:
http://opensource2.atlassian.com/projec ... se/HHH-511.
and here there is a discussion about it:
http://forum.hibernate.org/viewtopic.ph ... collection

Anyway, delete-orphan will delete a child, if you explicitly remove it from the collection. Look at this exampe:
Code:
Parent parent = session.load(Parent.class, parentId);
parent.getChildren().remove(child1);  // the child1 will be deleted

or

parent.getChildren().clear();  // all children of parent will be deleted


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.