I have mapped a many-to-many relation like this:
Code:
<class name="data.Customer" table="customers">
<id name="id" column="id" length="31">
<generator class="assigned" />
</id>
<set name="passes" table="customerPasses" cascade="delete">
<key column="customer" />
<many-to-many class="data.Pass" column="pass" />
</set>
</class>
<class name="data.Pass" table="passes">
<id name="id" column="id">
<generator class="assigned" />
</id>
<set name="customers" table="customerPasses" inverse="true" cascade="delete">
<key column="pass" />
<many-to-many class="data.Customer" column="customer" />
</set>
</class>
It's between customers and passes.
In the java classes the sets are declared as java.util.Set.
Now I want to clear all the relations related to a pass instance without deleting the instance it self.
I tried Set.clear(), this does clear the set in java but the relations in de DB remain.
I tried to iterate through pass.getCustomers(), which contains the relations from the pass, and delete it like pass.remove(customer instance), same as with Set.clear().
It does work when I iterate the same way but use customer.remove(pass instance).
This isn't very efficient, so does someone know how I can improve this?