Hi,
I'm not sure I understand what you mean by "break the relation in both directions".
Ideally, in my example Email does not and should not know about Person. It should be a unidirectional association Person -> Email.
This being said, if this is the only workaround I'm willing to look into it. Here are my mappings. How would you go in changing them to delete the "Email orphans"?
Code:
<class name="org.hibernate.bugs.orphandelete.entities.Person" table="PERSON"
lazy="false" dynamic-update="true">
<id name="id"
column="ID"
type="string"
length="32">
<generator class="uuid.hex"></generator>
</id>
<property name="name" type="string" update="true"
insert="true">
<column name="NAME" />
</property>
<many-to-one name="email"
column="EMAIL"
class="org.hibernate.bugs.orphandelete.entities.Email"
cascade="all"
outer-join="false"
update="true"
insert="true"
unique="true"/>
</class>
<class name="org.hibernate.bugs.orphandelete.entities.Email"
table="EMAIL"
lazy="false"
dynamic-update="true">
<id name="id"
column="ID"
type="string"
length="32">
<generator class="uuid.hex"></generator>
</id>
<property name="email"
type="string"
update="true"
insert="true">
<column name="EMAIL" />
</property>
</class>
It is important to note that it is not possible to set "delete-orphan" on a many-to-one or a one-to one association.
Thanks,
François