From the description of the Notch
& DynBrake
objects/tables, I would suggest to change the mapping. We do not need these objects/entities to be represented as separated objects. Because there is only composite-id ... it brings lot of troubles.
For these purposes Hibernate has composite-element
s. So let's change the Throttle.hbm.xml <map>
mapping (and throw the other files):
<map name="notch" cascade="all-delete-orphan" inverse="true">
<key column="THROTTLE_OBJID"/>
<index column="POSITION" type="int"/>
//<!--<one-to-many class="Notch"/>-->
<composite-element class="Notch">
<parent name="throttleObjId" />
<property name="seconds" type="int" column="SECONDS" />
</composite-element>
</map>
<map name="dynbrake" cascade="all-delete-orphan" inverse="true">
<key column="THROTTLE_OBJID"/>
<index column="POSITION" type="int"/>
//<!--<one-to-many class="DynBrake"/>-->
<composite-element class="DynBrake">
<parent name="throttleObjId" />
<property name="seconds" type="int" column="SECONDS" />
</composite-element>
</map>
The model will remain the same, but because of the nature of the Notch and DynBrake - mapping is simplified. Querying would be working, insert/update/delete as well. Also the cascading is changed to all-delete-orphan, which fits more into this scenario