Hello,
i used the table-per-subclass strategy to map inheritance.
Now, i would like to have the table rows of the subclass tables deleted when deleting an object from the parent class table.
Is this possible by adding a cascade-attribute to the mapping ?
Where should this attribute go ?
I only found documentation/examples for using cascade with sets etc.
The mapping looks as follows:
Code:
<class name="Component" table="component">
<id name="Id" type="java.lang.Integer">
<column name="id"/>
<generator class="increment"/>
</id>
<property name="Document" type="java.lang.Integer" insert="false" update="false">
<column name="document" length="5" not-null="false"/>
</property>
<property name="Position" type="java.lang.Integer">
<column name="position" length="5" not-null="false"/>
</property>
<many-to-one name="Fk_document" class="Document" property-ref="propfk_document">
<column name="document" not-null="false"/>
</many-to-one>
<joined-subclass name="Article" table="article">
<key column="id"/>
<property name="Title" type="java.lang.String">
<column name="title" length="200" not-null="false"/>
</property>
<property name="Author" type="java.lang.String">
<column name="author" length="200" not-null="false"/>
</property>
</joined-subclass>
<joined-subclass name="Text" table="text">
<key column="id"/>
<property name="Text" type="java.lang.String">
<column name="text" length="2000" not-null="false"/>
</property>
</joined-subclass>
</class>
</hibernate-mapping>
As one can see, i have a 'Document' Object which consists of 'Components' which can either be 'Article' or 'Text'.
The entries in the component table are deleted when deleting the document they belong to, but the article and text tables remain unchanged.
Thanks in advance.