Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.2.6
Hello,
I have 3 Entities, the have the following relations:
A(1)--(n)B(1)--(n)C
All realtions are parent-child, that means that when I delete
A, I want all associated Bs to be deleted as well. Also, when B
is deleted (as a result of deletion of A), I want the associated Cs
to be deleted.
I mapped all of the relations a follows:
A:
<list cascade="all-delete-orphan" fetch="join" lazy="false" name="bList">
<key column="AId"/>
<list-index column="listidx"/>
<one-to-many class="B"/>
</list>
B:
<list cascade="all-delete-orphan" fetch="join" lazy="false" name="cList">
<key column="BId"/>
<list-index column="listidx"/>
<one-to-many class="C"/>
</list>
If I just have an A instance and a associated B instance, the
deletion cascades well.
Problem is: If one or more Cn instances are associated to a given
B1, that in turn is associated with A1, the deletion of A1 does _not_
trigger the deletion of B1 and the Cns.
Instead, the foreign key field of B1 is set to null and the Cs are not
touched at all. Hibernate does not use the delete-cascade constraints
of the database but generates delete/update queries in both cases.
Any idea?
Best regards,
Stefan