for (Iterator<StoragePosition> it = mouse.getPositions().iterator(); it.hasNext() ;) {
StoragePosition sp = it.next();
if (! Util.isValid(sp.getPosition())) {
it.remove();
}
}
The "cascade" attribute configured in the Hibernate configuration file (hbm.xml) plays an important role in how it will behave when handling elements that have been removed from a Collection. In order for this to work the cascade attribute should have the following value: all-delete-orphan. A cascade value of save-update will not work. Below is a segment of the configuration file:
<set name="positions" inverse="true" table="mouse_storage_positions" cascade="all-delete-orphan" lazy="true" batch-size="8">
<key column="mouse_id" />
<one-to-many class="au.edu.apf.phenomebank.inventory.StoragePosition" />
</set>
No comments:
Post a Comment