Program: 177691
Project: 177691
Buggy source:
/** 
 * Makes name and column type bindings to given <code>field</code>. It also makes default name bindings to unnamed   {@link Index}es (or autoIncrement  {@link PrimaryKey} fields since it covers {@link Index})
 * @param entity used to generate index name if not specified.
 * @param field
 * @param namingPolicy
 * @param dataTypeMapper
 */
public static void makeBinding(Entity entity,Field field,PhysicalNamingPolicy namingPolicy,DataTypeMapper dataTypeMapper){
  if (field.getCustomName() != null) {
    Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    field.setGeneratedName(field.getCustomName());
  }
 else {
    field.setGeneratedName(PhysicalNameGenerator.format(field.getOriginalName(),namingPolicy));
  }
  if (field.getCustomType() != null) {
    Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    field.setType(field.getCustomType());
  }
 else {
    Class<?> fieldType=null;
    String customizedBindingType=null;
    if (field.isAnnotationPresent(OneToOne.class)) {
      Class<?> idType=getAutoIncrementTypeForClass(field.getClazz());
      fieldType=idType;
      customizedBindingType=getCustomizedBinding(field.getClazz());
      Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    }
 else     if (MappingSession.entityExists(field.getClazz())) {
      Class<?> idType=getAutoIncrementTypeForClass(field.getClazz());
      fieldType=idType;
      if (idType == null) {
        throw new NotDeclaredIdException(field.getClazz().getName());
      }
      customizedBindingType=getCustomizedBinding(field.getClazz());
      Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    }
 else {
      fieldType=field.getClazz();
    }
    if (customizedBindingType != null)     field.setType(customizedBindingType);
 else {
      if (fieldType.isEnum()) {
        field.setType(dataTypeMapper.getTypeFor(Enum.class));
      }
 else {
        field.setType(dataTypeMapper.getTypeFor(fieldType));
      }
    }
    Log.debug("String_Node_Str",field.getOriginalName(),field.getClazz().getName(),field.getGeneratedName(),field.getType(),customizedBindingType != null ? "String_Node_Str" : "String_Node_Str");
  }
  if (field.getIndex() != null) {
    if (field.getIndex().name() == null || "String_Node_Str".equals(field.getIndex().name())) {
      String indexName=null;
      if (field.isPrimaryKey()) {
        indexName=String.format(COMPOSITE_INDEX_FORMAT,PhysicalNameGenerator.capitalize(entity.getGeneratedName()),INDEX_POSTFIX);
      }
 else {
        indexName=String.format(FIELD_INDEX_FORMAT,PhysicalNameGenerator.capitalize(entity.getGeneratedName()),PhysicalNameGenerator.capitalize(field.getGeneratedName()),INDEX_POSTFIX);
      }
      Log.trace("String_Node_Str",field.getOriginalName(),indexName);
      field.getIndex().name(indexName);
    }
  }
}

Fixed version (ground truth):
/** 
 * Makes name and column type bindings to given <code>field</code>. It also makes default name bindings to unnamed   {@link Index}es (or autoIncrement  {@link PrimaryKey} fields since it covers {@link Index})
 * @param entity used to generate index name if not specified.
 * @param field
 * @param namingPolicy
 * @param dataTypeMapper
 */
public static void makeBinding(Entity entity,Field field,PhysicalNamingPolicy namingPolicy,DataTypeMapper dataTypeMapper){
  if (field.getCustomName() != null) {
    Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    field.setGeneratedName(field.getCustomName());
  }
 else {
    field.setGeneratedName(PhysicalNameGenerator.format(field.getOriginalName(),namingPolicy));
  }
  if (field.getCustomType() != null) {
    Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    field.setType(field.getCustomType());
  }
 else {
    Class<?> fieldType=null;
    String customizedBindingType=null;
    if (field.isAnnotationPresent(OneToOne.class)) {
      Class<?> idType=getAutoIncrementTypeForClass(field.getClazz());
      fieldType=idType;
      customizedBindingType=getCustomizedBinding(field.getClazz());
      Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    }
 else     if (MappingSession.entityExists(field.getClazz())) {
      Class<?> idType=getAutoIncrementTypeForClass(field.getClazz());
      fieldType=idType;
      if (idType == null) {
        throw new NotDeclaredIdException(field.getClazz().getName());
      }
      customizedBindingType=getCustomizedBinding(field.getClazz());
      Log.trace("String_Node_Str",entity.getOriginalName(),field.getOriginalName());
    }
 else {
      fieldType=field.getClazz();
    }
    if (customizedBindingType != null)     field.setType(customizedBindingType);
 else {
      if (fieldType != null)       if (fieldType.isEnum()) {
        field.setType(dataTypeMapper.getTypeFor(Enum.class));
      }
 else {
        field.setType(dataTypeMapper.getTypeFor(fieldType));
      }
    }
    Log.debug("String_Node_Str",field.getOriginalName(),field.getClazz().getName(),field.getGeneratedName(),field.getType(),customizedBindingType != null ? "String_Node_Str" : "String_Node_Str");
  }
  if (field.getIndex() != null) {
    if (field.getIndex().name() == null || "String_Node_Str".equals(field.getIndex().name())) {
      String indexName=null;
      if (field.isPrimaryKey()) {
        indexName=String.format(COMPOSITE_INDEX_FORMAT,PhysicalNameGenerator.capitalize(entity.getGeneratedName()),INDEX_POSTFIX);
      }
 else {
        indexName=String.format(FIELD_INDEX_FORMAT,PhysicalNameGenerator.capitalize(entity.getGeneratedName()),PhysicalNameGenerator.capitalize(field.getGeneratedName()),INDEX_POSTFIX);
      }
      Log.trace("String_Node_Str",field.getOriginalName(),indexName);
      field.getIndex().name(indexName);
    }
  }
}