Hi there, I'm stuck on the following problem:
I have two tables A and B. A has got a nullable foreign key to B. If I delete a row from A, I want the corresponding row in B to be deleted as well.
Here is what I tried in my .hbm.xml files:
<class name="A" table="A" > .... <many-to-one name="B" column="b" not-null="false" class="B" foreign-key="FK_a_to_b" cascade="all" lazy="false"/> ... </class>
If I now delete a row from A, the associated row in B remains where it is. I would have thought, the solution would be to use cascade="all-delete-orphan", but this does not seem to be defined for many-to-ones.
My question is: What would be the preferred way to do what I intend here?
Thanks a lot in advance!
|