I've reworked my parent child mappings based upon the patterns used in the suggested reading.
Child mapping...
Code:
<hibernate-mapping>
<class name="com.eis.service.link.InstructionStep" table="instruction_step">
<id name="ID" type="java.lang.Integer" unsaved-value="-1">
<column name="StepIntID" />
<generator class="native" />
</id>
<property name="title" type="java.lang.String">
<column name="StepTitle" length="50" />
</property>
<property name="displayOrder" type="java.lang.Integer">
<column name="StepDisplayOrder" />
</property>
<property name="message" type="java.lang.String">
<column name="StepMessage" length="65535" />
</property>
<many-to-one name="parent" column="LinkIntID" not-null="true"/>
</class>
</hibernate-mapping>
Parent mapping...
Code:
<set name="steps" lazy="false" inverse="true" cascade="all" order-by="StepDisplayOrder asc">
<key column="LinkIntID"/>
<one-to-many class="com.eis.service.link.InstructionStep"/>
</set>
This seems to work OK, except for one thing - deleting child entries.
If I first save a parent with three child entries, and then update the parent to have only 1 child then the two redundant child entries are not being deleted. Retrieving the parent will return an instance with 3 child entries.
Any ideas?
[/code]