|
Hi Everyone,
I have two tables with parent and child relationships.
I need to delete two records from both tables at one shot.
I created a collection in which i have parent object and this parent object again contain child object
And I passed this collection to deleteAll method.
Hibernatetemple().deleteAll(collection)
I have my mapping file like this
Parent hbm file:
<bag name="mmIdSet" lazy="true" inverse="true" cascade="all, delete-orphan">
<key column="EmpId"></key>
<one-to-many class="ChildClass"/>
</bag>
Child hbm file :
<many-to-one name="employee" class="ParentClass" cascade="all"
outer-join="auto" update="true" insert="true" column="EmpId" />
But when i try to delete..Im getting SQLException saying
Integrity Constraint Violated: child record found
And I can see the sql query like this
delete from parenttable where empid =?
It is trying to delete parent record first. Is there anyway to configure so that hibernate can delete child record first and then parent record
Please help me regarding this issue.
|