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?
|