-->
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: cascade=all-delete-orphan with many-to-one ?
PostPosted: Fri May 05, 2006 10:47 am 
Newbie

Joined: Thu Aug 25, 2005 5:33 pm
Posts: 10
Hi,

I have a hibernate object that references another hibernate object, eg

public class A {
private B b;

public B getB() {
return b;
}

public void setB(B b) {
this.b = b;
}

}

with the relevant part of A.hbm.xml being:
...
<many-to-one
name="b"
class="B"
cascade="all-delete-orphan"
outer-join="auto"
update="true"
insert="true"
column="b_id"
/>
...

Now, when I dereference B from A, as in a.setB(null) I want the B object to be removed from the database - hence I have been using cascade="all-delete-orphan". However, all I'm finding is that the b_id column is being set to null, and the record is not being deleted?

Version: 3.05

any ideas?


Row


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 12:01 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
In your scenario the setup is as follows:

Object B - maps- Object A1
Object B - maps- Object A2
Object B - maps- Object A3

And your tests are to delete Object B from Object A1 by setting it to null. If as per your idea, lets say Object B is removed from database. According to the cascade option, Object A2 and Object A3 should also be deleted because those child objects cannot exist without parent Object B. Is that your intention?


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.