Program: 31612
Project: 31612
Buggy source:
/** 
 * Execute a save request. Decides how the request is split depending upon characteristics of what is to be saved. Processes the response(s) and updates the mapping context.
 * @param context the CompileContext for this request
 */
public void executeSave(CompileContext context){
  Compiler compiler=context.getCompiler();
  compiler.useStatementFactory(new RowStatementFactory());
  List<ReferenceMapping> entityReferenceMappings=new ArrayList<>();
  List<ReferenceMapping> relReferenceMappings=new ArrayList<>();
  session.doInTransaction(() -> {
    if (compiler.hasStatementsDependentOnNewNodes()) {
      executeStatements(context,entityReferenceMappings,relReferenceMappings,compiler.createNodesStatements());
      List<Statement> statements=new ArrayList<>();
      statements.addAll(compiler.createRelationshipsStatements());
      statements.addAll(compiler.updateNodesStatements());
      statements.addAll(compiler.updateRelationshipStatements());
      statements.addAll(compiler.deleteRelationshipStatements());
      statements.addAll(compiler.deleteRelationshipEntityStatements());
      executeStatements(context,entityReferenceMappings,relReferenceMappings,statements);
    }
 else {
      List<Statement> statements=compiler.getAllStatements();
      executeStatements(context,entityReferenceMappings,relReferenceMappings,statements);
    }
  }
,Transaction.Type.READ_WRITE);
  updateNodeEntities(context,session,entityReferenceMappings);
  updateRelationshipEntities(context,session,relReferenceMappings);
  updateRelationships(context,session,relReferenceMappings);
}

Fixed version (ground truth):
/** 
 * Execute a save request. Decides how the request is split depending upon characteristics of what is to be saved. Processes the response(s) and updates the mapping context.
 * @param context the CompileContext for this request
 */
public void executeSave(CompileContext context){
  Compiler compiler=context.getCompiler();
  compiler.useStatementFactory(new RowStatementFactory());
  List<ReferenceMapping> entityReferenceMappings=new ArrayList<>();
  List<ReferenceMapping> relReferenceMappings=new ArrayList<>();
  boolean forceTx=compiler.updateNodesStatements().stream().anyMatch(st -> st.optimisticLockingConfig().isPresent()) || compiler.updateRelationshipStatements().stream().anyMatch(st -> st.optimisticLockingConfig().isPresent());
  session.doInTransaction(() -> {
    if (compiler.hasStatementsDependentOnNewNodes()) {
      executeStatements(context,entityReferenceMappings,relReferenceMappings,compiler.createNodesStatements());
      List<Statement> statements=new ArrayList<>();
      statements.addAll(compiler.createRelationshipsStatements());
      statements.addAll(compiler.updateNodesStatements());
      statements.addAll(compiler.updateRelationshipStatements());
      statements.addAll(compiler.deleteRelationshipStatements());
      statements.addAll(compiler.deleteRelationshipEntityStatements());
      executeStatements(context,entityReferenceMappings,relReferenceMappings,statements);
    }
 else {
      List<Statement> statements=compiler.getAllStatements();
      executeStatements(context,entityReferenceMappings,relReferenceMappings,statements);
    }
  }
,forceTx,Transaction.Type.READ_WRITE);
  updateNodeEntities(context,session,entityReferenceMappings);
  updateRelationshipEntities(context,session,relReferenceMappings);
  updateRelationships(context,session,relReferenceMappings);
}