Program: 177053
Project: 177053
Buggy source:
/** 
 * Gets the sql query from jpa.
 * @param entityMetadata the entity metadata
 * @param relations the relations
 * @param primaryKeys the primary keys
 * @return the sql query from jpa
 */
public String getSqlQueryFromJPA(EntityMetadata entityMetadata,List<String> relations,Set<String> primaryKeys){
  String aliasName="String_Node_Str" + entityMetadata.getTableName();
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(entityMetadata.getIdColumn().getName());
  for (  String column : entityMetadata.getColumnFieldNames()) {
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(aliasName);
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(column);
  }
  for (  String relation : relations) {
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(relation);
  }
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(entityMetadata.getTableName());
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  if (filter != null) {
    queryBuilder.append("String_Node_Str");
  }
  if (primaryKeys == null) {
    for (    Object o : conditions) {
      if (o instanceof FilterClause) {
        FilterClause clause=((FilterClause)o);
        queryBuilder.append(StringUtils.replace(clause.getProperty(),clause.getProperty().substring(0,clause.getProperty().indexOf("String_Node_Str")),aliasName));
        queryBuilder.append("String_Node_Str");
        queryBuilder.append(clause.getCondition());
        if (clause.getCondition().equalsIgnoreCase("String_Node_Str")) {
          queryBuilder.append("String_Node_Str");
        }
        queryBuilder.append("String_Node_Str");
        queryBuilder.append(clause.getValue());
      }
 else {
        queryBuilder.append("String_Node_Str");
        queryBuilder.append(o);
        queryBuilder.append("String_Node_Str");
      }
    }
  }
 else {
    queryBuilder.append(aliasName);
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(entityMetadata.getIdColumn().getName());
    queryBuilder.append("String_Node_Str");
    queryBuilder.append("String_Node_Str");
    int count=0;
    for (    String key : primaryKeys) {
      queryBuilder.append(key);
      if (++count != primaryKeys.size()) {
        queryBuilder.append("String_Node_Str");
      }
    }
  }
  return queryBuilder.toString();
}

Fixed version (ground truth):
/** 
 * Gets the sql query from jpa.
 * @param entityMetadata the entity metadata
 * @param relations the relations
 * @param primaryKeys the primary keys
 * @return the sql query from jpa
 */
public String getSqlQueryFromJPA(EntityMetadata entityMetadata,List<String> relations,Set<String> primaryKeys){
  String aliasName="String_Node_Str" + entityMetadata.getTableName();
  StringBuilder queryBuilder=new StringBuilder("String_Node_Str");
  queryBuilder.append(aliasName);
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(entityMetadata.getIdColumn().getName());
  for (  String column : entityMetadata.getColumnFieldNames()) {
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(aliasName);
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(column);
  }
  for (  String relation : relations) {
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(relation);
  }
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(entityMetadata.getTableName());
  queryBuilder.append("String_Node_Str");
  queryBuilder.append(aliasName);
  if (filter != null) {
    queryBuilder.append("String_Node_Str");
  }
  if (primaryKeys == null) {
    for (    Object o : conditions) {
      if (o instanceof FilterClause) {
        FilterClause clause=((FilterClause)o);
        queryBuilder.append(StringUtils.replace(clause.getProperty(),clause.getProperty().substring(0,clause.getProperty().indexOf("String_Node_Str")),aliasName));
        queryBuilder.append("String_Node_Str");
        queryBuilder.append(clause.getCondition());
        if (clause.getCondition().equalsIgnoreCase("String_Node_Str")) {
          queryBuilder.append("String_Node_Str");
        }
        queryBuilder.append("String_Node_Str");
        queryBuilder.append(clause.getValue());
      }
 else {
        queryBuilder.append("String_Node_Str");
        queryBuilder.append(o);
        queryBuilder.append("String_Node_Str");
      }
    }
  }
 else {
    queryBuilder.append(aliasName);
    queryBuilder.append("String_Node_Str");
    queryBuilder.append(entityMetadata.getIdColumn().getName());
    queryBuilder.append("String_Node_Str");
    queryBuilder.append("String_Node_Str");
    int count=0;
    for (    String key : primaryKeys) {
      queryBuilder.append(key);
      if (++count != primaryKeys.size()) {
        queryBuilder.append("String_Node_Str");
      }
 else {
        queryBuilder.append("String_Node_Str");
      }
    }
  }
  return queryBuilder.toString();
}