// add potentially newly discovered new objects
allObjectsList.put(object, object);
}
if (getUnitOfWorkChangeSet() == null) {
setUnitOfWorkChangeSet(new UnitOfWorkChangeSet());
}
calculateChanges(allObjectsList, (UnitOfWorkChangeSet)getUnitOfWorkChangeSet());
// write those changes to the database.
UnitOfWorkChangeSet changeSet = (UnitOfWorkChangeSet)getUnitOfWorkChangeSet();
if (!changeSet.hasChanges() && !changeSet.hasForcedChanges() && ! this.hasDeletedObjects() && ! this.hasModifyAllQueries()){
return;
}
try {
commitToDatabaseWithPreBuiltChangeSet(changeSet, false);
this.writesCompleted();
} catch (RuntimeException ex) {
clearFlushClearCache();
setLifecycle(WriteChangesFailed);
throw ex;
}
//bug 4730595: fix puts deleted objects in the UnitOfWorkChangeSet as they are removed.
getDeletedObjects().clear();
// unregister all deleted objects,
// keep them along with their original and backup values in unregisteredDeletedObjectsCloneToBackupAndOriginal
Enumeration enumDeleted = getObjectsDeletedDuringCommit().keys();
while(enumDeleted.hasMoreElements()) {
Object deletedObject = enumDeleted.nextElement();
Object[] backupAndOriginal = {getCloneMapping().get(deletedObject), getCloneToOriginals().get(deletedObject)};
unregisteredDeletedObjectsCloneToBackupAndOriginal.put(deletedObject, backupAndOriginal);
unregisterObject(deletedObject);
}
getObjectsDeletedDuringCommit().clear();
if(this.cumulativeUOWChangeSet == null) {
this.cumulativeUOWChangeSet = (UnitOfWorkChangeSet)getUnitOfWorkChangeSet();
} else {
//merge those changes back into the backup clones and the final uowChangeSet
this.cumulativeUOWChangeSet.mergeUnitOfWorkChangeSet((UnitOfWorkChangeSet)getUnitOfWorkChangeSet(), this, true);
}
//clean up
setUnitOfWorkChangeSet(new UnitOfWorkChangeSet());
Enumeration enumtr = insertedNewObjects.elements();
while (enumtr.hasMoreElements()) {
Object clone = enumtr.nextElement();
Object original = getNewObjectsCloneToOriginal().remove(clone);
if (original != null) {