Hi,
I have a parent class with one-to many-child classes (unidirectional) which in return has more one/many child classes and so on. The problem i am facing is when we try to delete an entity from the parent class, the child elements still persist in the database.
Parent hbm.xml
<composite id>
<key-column name = id1>
<key-column name = id2>
</composite-id>
<set class = child cascade="all" inverse="false">
<key>
<column name = id1>
<column name = id2>
<one-to-many = child>
</key>
Child class
<composite id>
<key-column name = id1>
<key-column name = id2>
</composite-id>
<set class = sub-child cascade="all" inverse="false">
<key>
<column name = id3>
<column name = id4>
<one-to-many = sub-child>
</key>
Sub-child class
<composite id>
<key-column name = id3>
<key-column name = id4>
</composite-id>
<property-name = prop1>
Test class
Entity entity = session.load(Clazz.class, serializable id)
session.delete(entity);
Please note the key columns will be repeated in each of the tables (we do not use foreign keys). Also, these relations are uni-directional. The primary key has to be referencing both the columns.
The insert function works fine and add values at all levels. Am i missing out something in the hbm files for delete? i have even tried inverse=true and cascade=all-delete-orphan but doesnt help. Also, the each of these classes are entities by themselves. so cannot include the columns of child class as composite-elements.
any pointers will be much appreciated.
Thanks.