-->
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: global delete_orphan
PostPosted: Tue Jan 13, 2009 3:36 am 
Newbie

Joined: Tue Jan 13, 2009 3:13 am
Posts: 2
Hi all :)
I have a field annotated @Cascade (value=DELETE_ORPHAN).
It works in our application for a long time, but now we've discovered a situation in which we need to move an object (the child in the mapping) to other parent. Suppose we have:
Code:
@Entity
public class Parent{
@OneToMany
@Cascade (value=DELETE_ORPHAN)
private List children;
...
}

And now we want to do (if parent1 and parent2 are instances of Parent):
Code:
parent1.getChildren().add(parent2.getChildren().get(0)

Is it possible to have a delete_orphan behavior, but in this "more general"way. That orphans which do not have any parent are deleted?

If not:
a workaround would be if I could say hibernate, that in application 1 it should use DELETE_ORPHAN, but in app2 (which updates some database data) it should not use cascade. Is that possible?
I'll be grateful for any help :)
Greets
Michal
PS write if sth is not clear :)


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.