-->
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.  [ 4 posts ] 
Author Message
 Post subject: How can I get cascade all-delete-orphans with a many-to-one?
PostPosted: Tue Mar 02, 2004 7:19 pm 
Newbie

Joined: Tue Mar 02, 2004 7:15 pm
Posts: 3
I have a persistent class A whose objects sometimes have a reference to instances of another persistent class B. I have it mapped many-to-one... but apparently I can't use all-delete-orphans in this case.

I understand, then, that if I remove the reference to the B in an A, and then delete the A, my B will stick around.

Is there a way to achieve the delete-orphans semantics without resorting to a Set and the standard parent-child inverse bidirectional mapping?

I'm sure this question has a simple answer. Thanks for your help.

Ben


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 5:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, you have to do this manually. "all-delete-orphan" is only really doable in a parent-child relationship. How should Hibernate know if other A's refer to the B?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 3:02 pm 
Newbie

Joined: Tue Mar 02, 2004 7:15 pm
Posts: 3
Okay, fair enough. In my situation, however, it is only ever the case that one single A refers to one single B.

If A's reference to a B is reseated to another B, it is guaranteed that the first B is no longer referred to by any A's, and thus can be deleted.

Is there a way to achieve automatic deletion in this case without resorting to a Set of children?

Ben


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 3:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Imho what you are having here is a one-to-one, not a many-to-one.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.