-->
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: newbie question-delete childs automatically on parent update
PostPosted: Mon Jun 21, 2010 9:56 am 
Newbie

Joined: Tue Feb 16, 2010 1:57 pm
Posts: 4
Hi, I have a parent child relationship.

In parent.hbm.xml

<set name="child" lazy="true" cascade="all, delete-orphan"
table="child_table">
<key column="parent_id" />
<one-to-many class="Child" />
</set>

I Child.hbm.xml

<many-to-one name="toParent"
class="Parent"
column="parent_id" />

The problem is that after updating parent with some code like this one:

Parent p = new Parent();
Set foo = new Hashset();
foo.add(new Child());
p.setChilds(foo);

I dont get old childs before this update deleted from child database table.
I know it is a basic question, but even reading the hibernate documentation I cannot figure it out how to get this basic operation done.


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.