| PersistentIdentifierBag returns an IteratorProxy on values when PersistentIdentifierBag.iterator() is called. A problem occurs, when remove() is called on that iterator, because it only removes the value from values but does not call PersistentIdentifierBag.beforeRemove(int) like PersistentIdentifierBag.remove(Object) does. This can cause an update cascade on the remaining entities, which can fail due to a unique constraint (as happened in our project). Even if it does not fail, it causes many useless updates, because the wrong entity was deleted and all other remaining entities get updated. (Note that always the last entity gets deleted, see (PersistentIdentifierBagg.getDeletes()), which is why it is important to call PersistentIdentifierBag.beforeRemove(int) first.) I suggest to implement PersistentIdentifierBag.iterator() properly or throw an UnsupportedOperationException. |