Program: 138681
Project: 138681
Buggy source:
@Override protected String createSqlStatement(Analysis analysis){
  this.cachedAnalysis=analysis;
  StringBuilder sql=new StringBuilder("String_Node_Str");
  EList<ModelElement> analysedElements=analysis.getContext().getAnalysedElements();
  if (analysedElements.isEmpty()) {
    this.errorMessage=Messages.getString("String_Node_Str",analysis.getName());
    return null;
  }
  Set<ColumnSet> fromPart=new HashSet<ColumnSet>();
  final Iterator<ModelElement> iterator=analysedElements.iterator();
  while (iterator.hasNext()) {
    ModelElement modelElement=iterator.next();
    TdColumn col=SwitchHelpers.COLUMN_SWITCH.doSwitch(modelElement);
    if (col == null) {
      this.errorMessage=Messages.getString("String_Node_Str",modelElement);
      return null;
    }
    Classifier owner=col.getOwner();
    if (owner == null) {
      this.errorMessage=Messages.getString("String_Node_Str",col.getName());
    }
    ColumnSet colSet=SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(owner);
    if (colSet == null) {
      this.errorMessage=Messages.getString("String_Node_Str",col.getName(),colSet);
      return null;
    }
    if (!analysis.getParameters().isStoreData()) {
      sql.append(this.quote(col.getName()));
      if (iterator.hasNext()) {
        sql.append(',');
      }
    }
    fromPart.add(colSet);
  }
  if (fromPart.size() != 1) {
    log.error("String_Node_Str" + fromPart.size() + "String_Node_Str");
    this.errorMessage="String_Node_Str";
    return null;
  }
  if (analysis.getParameters().isStoreData()) {
    List<TdColumn> columnList=TableHelper.getColumns(SwitchHelpers.TABLE_SWITCH.doSwitch(analysedElements.get(0).eContainer()));
    Iterator<TdColumn> iter=columnList.iterator();
    while (iter.hasNext()) {
      TdColumn column=iter.next();
      sql.append(this.quote(column.getName()));
      if (iter.hasNext()) {
        sql.append(',');
      }
    }
  }
  sql.append(dbms().from());
  ModelElement element=fromPart.iterator().next();
  Package parentRelation=PackageHelper.getCatalogOrSchema(fromPart.iterator().next());
  if (parentRelation instanceof Schema) {
    sql.append(dbms().toQualifiedName(null,parentRelation.getName(),element.getName()));
  }
 else   if (parentRelation instanceof Catalog) {
    String ownerUser=null;
    if (ConnectionUtils.isSybaseeDBProducts(dbms().getDbmsName())) {
      ownerUser=ColumnSetHelper.getTableOwner((ModelElement)element);
    }
    sql.append(dbms().toQualifiedName(parentRelation.getName(),ownerUser,element.getName()));
  }
  ModelElementAnalysisHandler handler=new ModelElementAnalysisHandler();
  handler.setAnalysis(analysis);
  String stringDataFilter=handler.getStringDataFilter();
  sql.append(GenericSQLHandler.WHERE_CLAUSE);
  String sqlStatement=sql.toString();
  sqlStatement=dbms().addWhereToStatement(sqlStatement,stringDataFilter);
  return sqlStatement;
}

Fixed version (ground truth):
@Override protected String createSqlStatement(Analysis analysis){
  this.cachedAnalysis=analysis;
  StringBuilder sql=new StringBuilder("String_Node_Str");
  EList<ModelElement> analysedElements=analysis.getContext().getAnalysedElements();
  if (analysedElements.isEmpty()) {
    this.errorMessage=Messages.getString("String_Node_Str",analysis.getName());
    return null;
  }
  Set<ColumnSet> fromPart=new HashSet<ColumnSet>();
  final Iterator<ModelElement> iterator=analysedElements.iterator();
  while (iterator.hasNext()) {
    ModelElement modelElement=iterator.next();
    TdColumn col=SwitchHelpers.COLUMN_SWITCH.doSwitch(modelElement);
    if (col == null) {
      this.errorMessage=Messages.getString("String_Node_Str",modelElement);
      return null;
    }
    Classifier owner=col.getOwner();
    if (owner == null) {
      this.errorMessage=Messages.getString("String_Node_Str",col.getName());
    }
    ColumnSet colSet=SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(owner);
    if (colSet == null) {
      this.errorMessage=Messages.getString("String_Node_Str",col.getName(),colSet);
      return null;
    }
    if (!analysis.getParameters().isStoreData()) {
      sql.append(this.quote(col.getName()));
      if (iterator.hasNext()) {
        sql.append(',');
      }
    }
    fromPart.add(colSet);
  }
  if (fromPart.size() != 1) {
    log.error("String_Node_Str" + fromPart.size() + "String_Node_Str");
    this.errorMessage="String_Node_Str";
    return null;
  }
  if (analysis.getParameters().isStoreData()) {
    List<TdColumn> columnList=TableHelper.getColumns(SwitchHelpers.TABLE_SWITCH.doSwitch(analysedElements.get(0).eContainer()));
    Iterator<TdColumn> iter=columnList.iterator();
    while (iter.hasNext()) {
      TdColumn column=iter.next();
      sql.append(this.quote(column.getName()));
      if (iter.hasNext()) {
        sql.append(',');
      }
    }
  }
  sql.append(dbms().from());
  ModelElement element=fromPart.iterator().next();
  Package parentRelation=PackageHelper.getParentPackage((MetadataTable)fromPart.iterator().next());
  if (parentRelation instanceof Schema) {
    sql.append(dbms().toQualifiedName(null,parentRelation.getName(),element.getName()));
  }
 else   if (parentRelation instanceof Catalog) {
    String ownerUser=null;
    if (ConnectionUtils.isSybaseeDBProducts(dbms().getDbmsName())) {
      ownerUser=ColumnSetHelper.getTableOwner((ModelElement)element);
    }
    sql.append(dbms().toQualifiedName(parentRelation.getName(),ownerUser,element.getName()));
  }
  ModelElementAnalysisHandler handler=new ModelElementAnalysisHandler();
  handler.setAnalysis(analysis);
  String stringDataFilter=handler.getStringDataFilter();
  sql.append(GenericSQLHandler.WHERE_CLAUSE);
  String sqlStatement=sql.toString();
  sqlStatement=dbms().addWhereToStatement(sqlStatement,stringDataFilter);
  return sqlStatement;
}