Program: 67638
Project: 67638
Buggy source:
/** 
 * INTERNAL: Commit the changes to any objects to the parent.
 * @param commitTransaction false if called by writeChanges as intent isnot to finalize the transaction.
 */
protected void commitToDatabaseWithChangeSet(boolean commitTransaction) throws DatabaseException, OptimisticLockException {
  try {
    startOperationProfile(SessionProfiler.UowCommit);
    boolean hasChanges=(this.unitOfWorkChangeSet != null) || hasCloneMapping() || hasDeletedObjects()|| hasModifyAllQueries()|| hasDeferredModifyAllQueries();
    if (hasChanges) {
      try {
        if (this.unitOfWorkChangeSet == null) {
          this.unitOfWorkChangeSet=new UnitOfWorkChangeSet(this);
        }
        calculateChanges((IdentityHashMap)((IdentityHashMap)getCloneMapping()).clone(),this.unitOfWorkChangeSet,true);
        getCommitManager().setIsActive(true);
      }
 catch (      RuntimeException exception) {
        copyStatementsCountIntoProperties();
        throw exception;
      }
      hasChanges=hasModifications();
    }
    if (hasChanges) {
      commitToDatabase(commitTransaction);
    }
 else {
      try {
        if (wasTransactionBegunPrematurely()) {
          if (commitTransaction) {
            setWasTransactionBegunPrematurely(false);
            setWasNonObjectLevelModifyQueryExecuted(false);
            commitTransaction();
          }
        }
        getCommitManager().setIsActive(false);
      }
 catch (      RuntimeException exception) {
        copyStatementsCountIntoProperties();
        throw exception;
      }
    }
  }
 catch (  RuntimeException exception) {
    handleException(exception);
  }
 finally {
    endOperationProfile(SessionProfiler.UowCommit);
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Commit the changes to any objects to the parent.
 * @param commitTransaction false if called by writeChanges as intent isnot to finalize the transaction.
 */
protected void commitToDatabaseWithChangeSet(boolean commitTransaction) throws DatabaseException, OptimisticLockException {
  try {
    startOperationProfile(SessionProfiler.UowCommit);
    boolean hasChanges=(this.unitOfWorkChangeSet != null) || hasCloneMapping() || hasDeletedObjects()|| hasModifyAllQueries()|| hasDeferredModifyAllQueries();
    if (hasChanges) {
      try {
        if (this.unitOfWorkChangeSet == null) {
          this.unitOfWorkChangeSet=new UnitOfWorkChangeSet(this);
        }
        calculateChanges(cloneMap(getCloneMapping()),this.unitOfWorkChangeSet,true);
        getCommitManager().setIsActive(true);
      }
 catch (      RuntimeException exception) {
        copyStatementsCountIntoProperties();
        throw exception;
      }
      hasChanges=hasModifications();
    }
    if (hasChanges) {
      commitToDatabase(commitTransaction);
    }
 else {
      try {
        if (wasTransactionBegunPrematurely()) {
          if (commitTransaction) {
            setWasTransactionBegunPrematurely(false);
            setWasNonObjectLevelModifyQueryExecuted(false);
            commitTransaction();
          }
        }
        getCommitManager().setIsActive(false);
      }
 catch (      RuntimeException exception) {
        copyStatementsCountIntoProperties();
        throw exception;
      }
    }
  }
 catch (  RuntimeException exception) {
    handleException(exception);
  }
 finally {
    endOperationProfile(SessionProfiler.UowCommit);
  }
}