Hi there,
Given the following relationship:
public class A
{
private Set tags; // a set of Tag
...
}
public class Tag {... }
and the mapping:
<class name="A" ... >
<set name="tags" table="A_TAG_XREF">
<key column="A_ID" not-null="true"/>
<many-to-many class="Tag" column="TAG_ID" not-found="ignore"/>
</set>
</class>
By default, if some Tag is contained in some A.tags, that Tag can't be deleted because of a foreign key constraint.
I'd like to be able to delete an instance of Tag and have it automatically removed from all associations in which it participates:
Tag t = ...
session.delete(t); // remove from all A.tags sets.
this would translate in SQL to:
delete from A_TAG_XREF where TAG_ID=<the id of the tag>
delete from tag_table where TAG_ID=<the id of the tag>
Is there any option that would implement this sort of semantics? Or I should manually remove an object from all its associations before deleting it?
Thanks a lot in advance!
Boris
|