| The problem here is that the generated XML mapping, shown below, generates a <key-many-to-one/> mapping, which implies a foreign-key constraint.
<composite-id name="originalId">
<key-many-to-one name="parent" class="Parent">
<column name="parent_id" length="255" scale="2" precision="19"/>
</key-many-to-one>
....
</composite-id>
When the foreign-key constraint gets added, this implies that the Parent entity cannot be removed from the base table without first purging all associated audit history to this Parent, which is not what is intended. The solution is to make sure that the <key-many-to-one/> includes specifying not to create a foreign-key constraint for this element.
<composite-id name="originalId">
<key-many-to-one name="parent" class="Parent" foreign-key="none">
<column name="parent_id" length="255" scale="2" precision="19"/>
</key-many-to-one>
....
</composite-id>
|