Hi everyone!
i'm facing a problem related to deleting a graph of objects:
i have a many to many relation between classes A and B.
B class knows about this relation, but A doesn't, i mean:
A.hbm.xml
Code:
(nothing about this many-to-many relation)
B.hbm.xml
Code:
<set name="abs" lazy="true" table="abs">
<key>
<column name="bid" />
</key>
<many-to-many class="A">
<column name="aid" />
</many-to-many>
</set>
if i try to delete an A object, i would want to also delete the associations with Bs objects, i mean to delete records in the intermediate table, however this is not happening, instead an SQL referential integrity error ocurrs.
the thing is that i have a similar configuration between class A and some class C, only difference is that both classes know about the relation, and those records in the intermediate table are deleted when i delete the A object...
A.hbm.xml
Code:
<set name="acs" lazy="true" table="acs">
<key>
<column name="aid" />
</key>
<many-to-many class="C">
<column name="cid" />
</many-to-many>
</set>
C.hbm.xml
Code:
<set name="acs" lazy="true" table="acs">
<key>
<column name="cid" />
</key>
<many-to-many class="A">
<column name="aid" />
</many-to-many>
</set>
so can anyone point me where is the problem or the correct way to do it?
i hope i'd explanied clearly enough what the issue was here.
regards![/i]