}
// it would be good if we also compare the new field element with
// the element in the transaction, when debug is set true
} else {
RelationCollection lazy = (RelationCollection) value;
// this RelationCollection has to clean up its state at the end of
// the
// transaction
tx.addTxSynchronizable(lazy);
ArrayList deleted = lazy.getDeleted();
if (!deleted.isEmpty()) {
if (_fieldMolder.isStored() && _fieldMolder.isCheckDirty()) {
flags.setUpdatePersist(true);
}
flags.setUpdateCache(true);
// if ( fieldMolder.isDependent() ) {
Iterator itor = deleted.iterator();
while (itor.hasNext()) {
flags.setUpdateCache(true);
Object toBeDeleted = lazy.find(itor.next());
if (toBeDeleted != null && tx.isPersistent(toBeDeleted)) {
if (_fieldMolder.isDependent()) {
tx.delete(toBeDeleted);
} else {
fieldClassMolder.removeRelation(tx, toBeDeleted,
this._classMolder, object);
}
// } else {
// // what to do if it happens?
}
}
}
ArrayList added = lazy.getAdded();
if (!added.isEmpty()) {
if (_fieldMolder.isStored() && _fieldMolder.isCheckDirty()) {
flags.setUpdatePersist(true);
}
flags.setUpdateCache(true);
if (_fieldMolder.isDependent()) {
Iterator itor = added.iterator();
while (itor.hasNext()) {
Object toBeAdded = lazy.find(itor.next());
if (toBeAdded != null) {
tx.markCreate(fieldClassMolder, toBeAdded, oid);
// } else {
// // what to do if it happens?
}
}
} else if (tx.isAutoStore()) {
Iterator itor = added.iterator();
while (itor.hasNext()) {
Object toBeAdded = lazy.find(itor.next());
if (toBeAdded != null) {
if (!tx.isRecorded(toBeAdded)) {
tx.markCreate(fieldClassMolder, toBeAdded, null);
}
}