Hibernate version:3.0
I have two classes, parent and child, where one parent can have a set of children. Now, I would like to delete a child.
Is there some way for me to delete this child, just using session.delete(child), without also having to remove the child object from the set of children stored in the parent object?
like:
public void delete(Child selectedChildToRemove) {
children.getParent().removeChild(selectedChildToRemove); //could I skip this line?
session.delete(selectedChildToRemove);
session.flush();
}
It seems to work, but i'm unsure wheter its the right way to go, if I configure the set like:
<class name="Parent" table="COUNTRY">
...
<set name="children" lazy="false" inverse="true" cascade="all-delete-orphan">
<key column="PARENT_ID" not-null="false" />
<one-to-many class="Child" />
</set>
</class>
All help is very apreciated.
Thanks
|