* org.exolab.castor.persist.ClassMolder, java.lang.Object)
*/
public final UpdateAndRemovedFlags removeRelation(final TransactionContext tx,
final Object object, final ClassMolder relatedMolder,
final Object relatedObject) {
UpdateAndRemovedFlags flags = new UpdateAndRemovedFlags();
// remove the object from the collection
ClassMolder fieldClassMolder = _fieldMolder.getFieldClassMolder();
ClassMolder relatedBaseMolder = relatedMolder;
while (fieldClassMolder != relatedBaseMolder
&& relatedBaseMolder != null) {
relatedBaseMolder = relatedBaseMolder.getExtends();
}
if (fieldClassMolder == relatedBaseMolder) {
boolean changed = false;
Object related = _fieldMolder.getValue(object, tx.getClassLoader());
if (related instanceof RelationCollection) {
RelationCollection lazy = (RelationCollection) related;
changed = lazy.remove(relatedObject);
} else {
Iterator itor = ClassMolderHelper.getIterator(related);
while (itor.hasNext()) {
Object o = itor.next();
if (o == relatedObject) {
changed = true;
itor.remove();
}
}
}
if (changed) {
flags.setUpdateCache(true);
flags.setUpdatePersist(false);
flags.setRemoved(true);
}
}
return flags;
}