Program: 39252
Project: 39252
Buggy source:
private void deleteEntity(final InternalDataDefinition dataDefinition,final Long entityId){
  Object databaseEntity=getDatabaseEntity(dataDefinition,entityId);
  checkNotNull(databaseEntity,"String_Node_Str",dataDefinition.getPluginIdentifier() + "String_Node_Str" + dataDefinition.getName(),entityId);
  Entity entity=get(dataDefinition,entityId);
  priorityService.deprioritizeEntity(dataDefinition,databaseEntity);
  Map<String,FieldDefinition> fields=dataDefinition.getFields();
  for (  FieldDefinition fieldDefinition : fields.values()) {
    if (fieldDefinition.getType() instanceof HasManyType) {
      HasManyType hasManyFieldType=(HasManyType)fieldDefinition.getType();
      EntityList children=entity.getHasManyField(fieldDefinition.getName());
      InternalDataDefinition childDataDefinition=(InternalDataDefinition)hasManyFieldType.getDataDefinition();
      if (HasManyType.Cascade.NULLIFY.equals(hasManyFieldType.getCascade()) && children != null) {
        for (        Entity child : children) {
          child.setField(hasManyFieldType.getJoinFieldName(),null);
          child=save(childDataDefinition,child);
          if (!child.isValid()) {
            throw new IllegalStateException(String.format("String_Node_Str",expressionService.getValue(entity,dataDefinition.getIdentifierExpression(),Locale.ENGLISH)));
          }
        }
      }
    }
    if (fieldDefinition.getType() instanceof TreeType) {
      TreeType treeFieldType=(TreeType)fieldDefinition.getType();
      EntityTree children=entity.getTreeField(fieldDefinition.getName());
      InternalDataDefinition childDataDefinition=(InternalDataDefinition)treeFieldType.getDataDefinition();
      if (TreeType.Cascade.NULLIFY.equals(treeFieldType.getCascade()) && children != null) {
        for (        Entity child : children) {
          child.setField(treeFieldType.getJoinFieldName(),null);
          child=save(childDataDefinition,child);
          if (!child.isValid()) {
            throw new IllegalStateException(String.format("String_Node_Str",expressionService.getValue(entity,dataDefinition.getIdentifierExpression(),Locale.ENGLISH)));
          }
        }
      }
    }
  }
  try {
    hibernateService.getCurrentSession().delete(databaseEntity);
    hibernateService.getCurrentSession().flush();
  }
 catch (  ConstraintViolationException e) {
    throw new IllegalStateException(String.format("String_Node_Str",expressionService.getValue(entity,dataDefinition.getIdentifierExpression(),Locale.ENGLISH)),e);
  }
  logEntityInfo(dataDefinition,entityId,"String_Node_Str");
}

Fixed version (ground truth):
private void deleteEntity(final InternalDataDefinition dataDefinition,final Long entityId){
  Object databaseEntity=getDatabaseEntity(dataDefinition,entityId);
  checkNotNull(databaseEntity,"String_Node_Str",dataDefinition.getPluginIdentifier() + "String_Node_Str" + dataDefinition.getName(),entityId);
  Entity entity=get(dataDefinition,entityId);
  priorityService.deprioritizeEntity(dataDefinition,databaseEntity);
  Map<String,FieldDefinition> fields=dataDefinition.getFields();
  for (  FieldDefinition fieldDefinition : fields.values()) {
    if (fieldDefinition.getType() instanceof HasManyType) {
      HasManyType hasManyFieldType=(HasManyType)fieldDefinition.getType();
      EntityList children=entity.getHasManyField(fieldDefinition.getName());
      InternalDataDefinition childDataDefinition=(InternalDataDefinition)hasManyFieldType.getDataDefinition();
      if (HasManyType.Cascade.NULLIFY.equals(hasManyFieldType.getCascade()) && children != null) {
        for (        Entity child : children) {
          child.setField(hasManyFieldType.getJoinFieldName(),null);
          child=save(childDataDefinition,child);
          if (!child.isValid()) {
            throw new IllegalStateException(getConstraintViolationMessage(dataDefinition,entity));
          }
        }
      }
    }
    if (fieldDefinition.getType() instanceof TreeType) {
      TreeType treeFieldType=(TreeType)fieldDefinition.getType();
      EntityTree children=entity.getTreeField(fieldDefinition.getName());
      InternalDataDefinition childDataDefinition=(InternalDataDefinition)treeFieldType.getDataDefinition();
      if (TreeType.Cascade.NULLIFY.equals(treeFieldType.getCascade()) && children != null) {
        for (        Entity child : children) {
          child.setField(treeFieldType.getJoinFieldName(),null);
          child=save(childDataDefinition,child);
          if (!child.isValid()) {
            throw new IllegalStateException(getConstraintViolationMessage(dataDefinition,entity));
          }
        }
      }
    }
  }
  try {
    hibernateService.getCurrentSession().delete(databaseEntity);
    hibernateService.getCurrentSession().flush();
  }
 catch (  ConstraintViolationException e) {
    throw new IllegalStateException(getConstraintViolationMessage(dataDefinition,entity),e);
  }
  logEntityInfo(dataDefinition,entityId,"String_Node_Str");
}