use of org.datanucleus.flush.CollectionRemoveOperation in project datanucleus-core by datanucleus.
the class HashSet method removeAll.
/**
* Method to remove all elements from the collection from the set.
* @param elements The collection of elements to remove
* @return Whether it was removed ok.
*/
public boolean removeAll(java.util.Collection elements) {
if (elements == null) {
throw new NullPointerException();
} else if (elements.isEmpty()) {
return true;
}
boolean success = delegate.removeAll(elements);
if (ownerOP != null) {
if (ownerOP.getExecutionContext().getManageRelations()) {
// Relationship management
Iterator iter = elements.iterator();
RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
while (iter.hasNext()) {
relMgr.relationRemove(ownerMmd.getAbsoluteFieldNumber(), iter.next());
}
}
// Cascade delete
if (SCOUtils.useQueuedUpdate(ownerOP)) {
// Queue any cascade delete
Iterator iter = elements.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().addOperationToQueue(new CollectionRemoveOperation(ownerOP, ownerMmd.getAbsoluteFieldNumber(), iter.next(), true));
}
} else if (SCOUtils.hasDependentElement(ownerMmd)) {
// Perform the cascade delete
Iterator iter = elements.iterator();
while (iter.hasNext()) {
ownerOP.getExecutionContext().deleteObjectInternal(iter.next());
}
}
}
if (success) {
makeDirty();
if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
ownerOP.getExecutionContext().processNontransactionalUpdate();
}
}
return success;
}
Aggregations