-->
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: Transitive persistence
PostPosted: Thu Apr 29, 2010 12:19 pm 
Newbie

Joined: Thu Mar 11, 2010 7:39 am
Posts: 3
Query relating to the cascade option 'delete-orphan'

I have a table 'TableFoo' having a foreign key relationship with itself.
This is how my hbm file looks like
<set name="children" cascade="all,delete-orphan" inverse="true"
fetch="select" lazy="false">
<key column="parentId" />
<one-to-many class="com.... .hb.FooClass" />
</set>

<many-to-one name="parent"
class="com.... .hb.FooClass"
column="parentId" />

Now, in a session I pull out a particular record with all its children to an object fooObject of type FooClass.
In another session, I remove one of the children from fooObject by fooObject.getChildren().iterator().remove().
and do a saveOrUpdate(fooObject). I suppose this should delete the particular child from the DB. But its not!!

The same scenario works fine for me when a table has a foreign key mapped to another table.
Thanks,


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.