-->
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: Problem with update query cascade
PostPosted: Fri Dec 11, 2009 4:15 pm 
Newbie

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 1
Hi,

I have a parent class (maps child in a java.util.Set) and child bidirectional relationship. My understanding says that if I remove a child from the Set within the Parent, and call update on parent, the child will be deleted. I.e.

Parent parent = session.getParent(Parent.class, Id);
parent.setChildSet(new java.util.Set());

session.saveOrUpdate(parent);

The above code should delete all the children associated with Parent.

the following is the child mapping in parent HBM:

<set name="childSet" inverse="true" cascade="all-delete-orphan" lazy="false" >
<key column="childId" on-delete="cascade" />
<one-to-many class="Child" />
</set>

And the parent mapping looks like:

<many-to-one name="parent" column="parentId" class="Parent" not-null="true" cascade="all" />

What am i doing wrong here?


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.