Hi All,
I am having a serious problem that I just can't solve. I have a parent object with multiple children. I have updated the classnames in this example to protect our project but the idea is the same. Here are the mappings.
Parent mapping contains:
Code:
<set name="childrenSet" cascade="delete-orphan">
<key>
<column name="PARENT_ID" precision="15" scale="0" not-null="true" />
</key>
<one-to-many class="com.test.model.Child" />
</set>
Child mapping contains:
Code:
<many-to-one name="parentObj" class="com.test.model.Parent" update="false" insert="false" fetch="select">
<column name="PARENT_ID" precision="15" scale="0" not-null="true" />
</many-to-one>
In my code I execute the following:
getHibernateTemplate().delete( parent );
In this example the parent object is an instance of a parent object loaded by hibernate.
When the code is executed I get an error stating that a Child row cannot be update because PARENT_ID cant be set to null. It seams as if Hibernate is trying to detach the parent from the child by setting the reference to null instead of deleting the child entirely. If this is true, isnt this a bug in hibernate?
Thanks in advance,
Martyn