Hi,
I have a Man class that contains a Set ou House class.
The House class also contains a Set of Man class.
So there is a n-m relationship between Man and House that goes both way, which means there is a relationship table between Man and House that stores Man.id and House.id.
If I declare the in Man mapping:
<set name="houses" table="MAN_HOUSE" inverse="true" lazy="true">
<key column="MAN_ID"/>
<many-to-many class="House" column="HOUSE_ID"/>
</set >
and in the House mapping:
<set name="men" table="MAN_HOUSE" lazy="true">
<key column="HOUSE_ID"/>
<many-to-many class="Man" column="MAN_ID"/>
</set >
when I use Session.delete(Man) then Hibernate deletes from MAN_HOUSE (the relationship table) before deleting from Man, which is correct.
BUT, when I use Session.delete(House) then Hibernate doesn't delete from MAN_HOUSE before deleting from House, which is bad!
Any idea what needs to be modified to make this work?
thanks!
|