Program: 139713
Project: 139713
Buggy source:
public String createJoinConditionAsString(List<JoinElement> joinElements){
  if (joinElements.isEmpty()) {
    return "String_Node_Str";
  }
  StringBuilder builder=new StringBuilder();
  for (  JoinElement joinElement : joinElements) {
    ModelElement colA=joinElement.getColA();
    String tableA=getTableName(colA);
    String tableAliasA=joinElement.getTableAliasA();
    String columnAName=getColumnName(colA);
    String columnAliasA=joinElement.getColumnAliasA();
    boolean hasTableAliasA=!StringUtils.isEmpty(tableAliasA);
    boolean hasColumnAliasA=!StringUtils.isEmpty(columnAliasA);
    ModelElement colB=joinElement.getColB();
    String tableB=getTableName(colB);
    String tableAliasB=joinElement.getTableAliasB();
    String columnBName=getColumnName(colB);
    String columnAliasB=joinElement.getColumnAliasB();
    boolean hasTableAliasB=!StringUtils.isEmpty(tableAliasB);
    boolean hasColumnAliasB=!StringUtils.isEmpty(columnAliasB);
    String operator=joinElement.getOperator();
    if (hasTableAliasA) {
      builder.append(surroundWithSpaces(tableAliasA));
    }
    builder.append("String_Node_Str");
    builder.append(surroundWithSpaces(quote(tableB)));
    if (hasTableAliasB) {
      builder.append(surroundWithSpaces(tableAliasB));
    }
    builder.append("String_Node_Str");
    String tA=hasTableAliasA ? null : quote(tableA);
    String tB=hasTableAliasB ? null : quote(tableB);
    String cA=hasColumnAliasA ? columnAliasA : quote(columnAName);
    String cB=hasColumnAliasB ? columnAliasB : quote(columnBName);
    createJoinClause(builder,tA,cA,tB,cB,operator);
  }
  return builder.toString();
}

Fixed version (ground truth):
public String createJoinConditionAsString(ModelElement leftTable,List<JoinElement> joinElements){
  if (joinElements.isEmpty()) {
    return "String_Node_Str";
  }
  StringBuilder builder=new StringBuilder();
  for (  JoinElement joinElement : joinElements) {
    ModelElement colA=joinElement.getColA();
    String tableA=getTableName(colA);
    String tableAliasA=joinElement.getTableAliasA();
    String columnAName=getColumnName(colA);
    String columnAliasA=joinElement.getColumnAliasA();
    boolean hasTableAliasA=!StringUtils.isEmpty(tableAliasA);
    boolean hasColumnAliasA=!StringUtils.isEmpty(columnAliasA);
    ModelElement colB=joinElement.getColB();
    String tableB=getTableName(colB);
    String tableAliasB=joinElement.getTableAliasB();
    String columnBName=getColumnName(colB);
    String columnAliasB=joinElement.getColumnAliasB();
    boolean hasTableAliasB=!StringUtils.isEmpty(tableAliasB);
    boolean hasColumnAliasB=!StringUtils.isEmpty(columnAliasB);
    String operator=joinElement.getOperator();
    if (joinClauseStartsWithWrongTable(leftTable,getTable(colB)) && !hasTableAliasA && !hasTableAliasB) {
      buildJoinClause(builder,tableB,tableAliasB,columnBName,columnAliasB,hasTableAliasB,hasColumnAliasB,tableA,tableAliasA,columnAName,columnAliasA,hasTableAliasA,hasColumnAliasA,operator);
    }
 else {
      buildJoinClause(builder,tableA,tableAliasA,columnAName,columnAliasA,hasTableAliasA,hasColumnAliasA,tableB,tableAliasB,columnBName,columnAliasB,hasTableAliasB,hasColumnAliasB,operator);
    }
  }
  return builder.toString();
}