use of org.datanucleus.state.LifeCycleState in project datanucleus-core by datanucleus.
the class ManagedRelationsHandler method execute.
public void execute() {
if (managedRelationDetails.isEmpty()) {
return;
}
try {
executing = true;
if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
NucleusLogger.PERSISTENCE.debug(Localiser.msg("013000"));
}
if (performChecks) {
// Tests for negative situations where inconsistently assigned
Iterator<Map.Entry<ObjectProvider, RelationshipManager>> managedRelEntryIter = managedRelationDetails.entrySet().iterator();
while (managedRelEntryIter.hasNext()) {
Map.Entry<ObjectProvider, RelationshipManager> managedRelEntry = managedRelEntryIter.next();
ObjectProvider op = managedRelEntry.getKey();
LifeCycleState lc = op.getLifecycleState();
if (lc == null || lc.isDeleted()) {
// Has been deleted so ignore all relationship changes
continue;
}
managedRelEntry.getValue().checkConsistency();
}
}
// Process updates to manage the other side of the relations
Iterator<Map.Entry<ObjectProvider, RelationshipManager>> managedRelEntryIter = managedRelationDetails.entrySet().iterator();
while (managedRelEntryIter.hasNext()) {
Map.Entry<ObjectProvider, RelationshipManager> managedRelEntry = managedRelEntryIter.next();
ObjectProvider op = managedRelEntry.getKey();
LifeCycleState lc = op.getLifecycleState();
if (lc == null || lc.isDeleted()) {
// Has been deleted so ignore all relationship changes
continue;
}
RelationshipManager relMgr = managedRelEntry.getValue();
relMgr.process();
relMgr.clearFields();
}
managedRelationDetails.clear();
if (NucleusLogger.PERSISTENCE.isDebugEnabled()) {
NucleusLogger.PERSISTENCE.debug(Localiser.msg("013001"));
}
} finally {
executing = false;
}
}
Aggregations