I have a mapping as follows
Code:
<class name="Parent" table="parents">
<key>
<column name="parent_id", sql-type="char(36)"/>
</key>
<list name="children" cascade="all">
<key>
<column name="parent_id" sql-type="char(36)"/>
</key>
<index column="index"/>
<one-to-many class="Child"/>
</list>
</class>
<class name="Child" table="children">
<key>
<column name="child_id" sql-type="char(36)"/>
</key>
</class>
Now I have a Parent object with some Child objects contained in it. If I do a Parent.getChildren().clear(), then I wanted to know if all the associated entries in the children table deleted?
It doesnt seem to do so in my code. I am trying to get the semantics of collections right. This mapping is supposed to be a one-to-many from Parent to Child, with all operations on Parent cascaded onto Child, but not vice-versa.
Or do I have to manually delete each Child entry apart from doing the Parent.getChildren().clear()? If this is the case, is there a way I can avoid this by some means in the mapping?