Program: 34957
Project: 34957
Buggy source:
private void buildForeignKey(final JoinColumn joinColumn,final Attribute<?,?> jpaAttribute) throws ODataJPAModelException, ODataJPARuntimeException {
  joinColumnNames=joinColumnNames == null ? new ArrayList<String[]>() : joinColumnNames;
  String[] name={null,null};
  name[0]=joinColumn.name().equals("String_Node_Str") == true ? jpaAttribute.getName() : joinColumn.name();
  EntityType<?> referencedEntityType=null;
  if (jpaAttribute.isCollection()) {
    referencedEntityType=metaModel.entity(((PluralAttribute<?,?,?>)currentAttribute).getElementType().getJavaType());
  }
 else {
    referencedEntityType=metaModel.entity(jpaAttribute.getJavaType());
  }
  if (joinColumn.referencedColumnName().equals("String_Node_Str")) {
    for (    Attribute<?,?> referencedAttribute : referencedEntityType.getAttributes()) {
      if (referencedAttribute.getPersistentAttributeType() == PersistentAttributeType.BASIC && ((SingularAttribute<?,?>)referencedAttribute).isId()) {
        AnnotatedElement annotatedElement=(AnnotatedElement)referencedAttribute.getJavaMember();
        Column referencedColumn=null;
        if (annotatedElement != null) {
          referencedColumn=annotatedElement.getAnnotation(Column.class);
        }
        if (referencedColumn != null) {
          name[1]=referencedColumn.name();
        }
 else {
          name[1]=referencedAttribute.getName();
        }
        joinColumnNames.add(name);
        currentRefAttribute=referencedAttribute;
        break;
      }
    }
  }
 else {
    for (    Attribute<?,?> referencedAttribute : referencedEntityType.getAttributes()) {
      AnnotatedElement annotatedElement2=(AnnotatedElement)referencedAttribute.getJavaMember();
      if (annotatedElement2 != null) {
        Column referencedColumn=annotatedElement2.getAnnotation(Column.class);
        if (referencedColumn != null && referencedColumn.name().equals((joinColumn.referencedColumnName()))) {
          name[1]=referencedColumn.name();
          joinColumnNames.add(name);
          currentRefAttribute=referencedAttribute;
          break;
        }
      }
    }
  }
  if (currentRefAttribute == null) {
    throw ODataJPAModelException.throwException(ODataJPAModelException.REF_ATTRIBUTE_NOT_FOUND.addContent(referencedEntityType.getName()),null);
  }
  if (joinColumn.insertable() && joinColumn.updatable()) {
    currentSimpleProperty=new SimpleProperty();
    properties.add(buildSimpleProperty(currentRefAttribute,currentSimpleProperty,joinColumn));
    if (joinColumn.nullable()) {
      currentSimpleProperty.getFacets();
    }
  }
}

Fixed version (ground truth):
private void buildForeignKey(final JoinColumn joinColumn,final Attribute<?,?> jpaAttribute) throws ODataJPAModelException, ODataJPARuntimeException {
  joinColumnNames=joinColumnNames == null ? new ArrayList<String[]>() : joinColumnNames;
  String[] name={null,null};
  name[0]=joinColumn.name().equals("String_Node_Str") == true ? jpaAttribute.getName() : joinColumn.name();
  EntityType<?> referencedEntityType=null;
  if (jpaAttribute.isCollection()) {
    referencedEntityType=metaModel.entity(((PluralAttribute<?,?,?>)currentAttribute).getElementType().getJavaType());
  }
 else {
    referencedEntityType=metaModel.entity(jpaAttribute.getJavaType());
  }
  if (joinColumn.referencedColumnName().equals("String_Node_Str")) {
    for (    Attribute<?,?> referencedAttribute : referencedEntityType.getAttributes()) {
      if (referencedAttribute.getPersistentAttributeType() == PersistentAttributeType.BASIC && ((SingularAttribute<?,?>)referencedAttribute).isId()) {
        AnnotatedElement annotatedElement=(AnnotatedElement)referencedAttribute.getJavaMember();
        Column referencedColumn=null;
        if (annotatedElement != null) {
          referencedColumn=annotatedElement.getAnnotation(Column.class);
        }
        if (referencedColumn != null) {
          name[1]=referencedColumn.name();
        }
 else {
          name[1]=referencedAttribute.getName();
        }
        joinColumnNames.add(name);
        currentRefAttribute=referencedAttribute;
        break;
      }
    }
  }
 else {
    for (    Attribute<?,?> referencedAttribute : referencedEntityType.getAttributes()) {
      AnnotatedElement annotatedElement2=(AnnotatedElement)referencedAttribute.getJavaMember();
      if (annotatedElement2 != null) {
        String refColName=getReferenceColumnName(annotatedElement2,referencedAttribute);
        if (refColName.equals((joinColumn.referencedColumnName()))) {
          name[1]=refColName;
          joinColumnNames.add(name);
          currentRefAttribute=referencedAttribute;
          break;
        }
      }
    }
  }
  if (currentRefAttribute == null) {
    throw ODataJPAModelException.throwException(ODataJPAModelException.REF_ATTRIBUTE_NOT_FOUND.addContent(joinColumn.referencedColumnName() + "String_Node_Str" + referencedEntityType.getName()),null);
  }
  if (joinColumn.insertable() && joinColumn.updatable()) {
    currentSimpleProperty=new SimpleProperty();
    properties.add(buildSimpleProperty(currentRefAttribute,currentSimpleProperty,joinColumn));
    if (joinColumn.nullable()) {
      currentSimpleProperty.getFacets();
    }
  }
}