nus-yam/ex-repair huggingface dataset:
Program: 168895
Project: 168895
Buggy source:
@Override protected Query getQuery(Map<DbmsModificationState,String> includedModificationStates){
  Query query;
  if (jpaProvider.supportsInsertStatement() && dbmsDialect.supportsWithClause()) {
    List<Query> participatingQueries=new ArrayList<Query>();
    query=em.createQuery(getBaseQueryStringWithCheck());
    StringBuilder sqlSb=new StringBuilder(cbf.getExtendedQuerySupport().getSql(em,query));
    boolean isEmbedded=this instanceof ReturningBuilder;
    StringBuilder withClause=applyCtes(sqlSb,query,isEmbedded,participatingQueries);
    String[] returningColumns=getReturningColumns();
    Map<String,String> addedCtes=applyExtendedSql(sqlSb,false,isEmbedded,withClause,returningColumns,includedModificationStates);
    String finalSql=sqlSb.toString();
    participatingQueries.add(query);
    if (mainQuery.cteManager.hasCtes() && returningAttributeBindingMap.isEmpty() && !dbmsDialect.usesExecuteUpdateWhenWithClauseInModificationQuery()) {
      query=getCountExampleQuery();
    }
    query=new CustomSQLQuery(participatingQueries,query,(CommonQueryBuilder<?>)this,cbf.getExtendedQuerySupport(),finalSql,addedCtes);
    query.setFirstResult(firstResult);
    query.setMaxResults(maxResults);
  }
 else {
    query=em.createQuery(getBaseQueryStringWithCheck());
  }
  parameterManager.parameterizeQuery(query);
  return query;
}

Fixed version (ground truth):
@Override protected Query getQuery(Map<DbmsModificationState,String> includedModificationStates){
  Query query;
  if (jpaProvider.supportsInsertStatement()) {
    List<Query> participatingQueries=new ArrayList<Query>();
    query=em.createQuery(getBaseQueryStringWithCheck());
    StringBuilder sqlSb=new StringBuilder(cbf.getExtendedQuerySupport().getSql(em,query));
    boolean isEmbedded=this instanceof ReturningBuilder;
    StringBuilder withClause=applyCtes(sqlSb,query,isEmbedded,participatingQueries);
    String[] returningColumns=getReturningColumns();
    Map<String,String> addedCtes=applyExtendedSql(sqlSb,false,isEmbedded,withClause,returningColumns,includedModificationStates);
    String finalSql=sqlSb.toString();
    participatingQueries.add(query);
    for (    Query q : participatingQueries) {
      parameterManager.parameterizeQuery(q);
    }
    boolean hasCtes=withClause != null && withClause.length() != 0 || addedCtes != null && !addedCtes.isEmpty();
    if (hasCtes && returningAttributeBindingMap.isEmpty() && !dbmsDialect.usesExecuteUpdateWhenWithClauseInModificationQuery()) {
      query=getCountExampleQuery();
    }
    query=new CustomSQLQuery(participatingQueries,query,(CommonQueryBuilder<?>)this,cbf.getExtendedQuerySupport(),finalSql,addedCtes);
    query.setFirstResult(firstResult);
    query.setMaxResults(maxResults);
  }
 else {
    query=em.createQuery(getBaseQueryStringWithCheck());
    parameterManager.parameterizeQuery(query);
  }
  return query;
}
Program: 168896
Project: 168896
Buggy source:
@Override public String applySqlInlined(String sql,boolean isSubquery,Integer limit,Integer offset){
  if (limit == null && offset == null) {
    return sql;
  }
  StringBuilder sb=new StringBuilder(sql.length() + length);
  sb.append(sql);
  applySql(sb,isSubquery,limit == null ? null : limit.toString(),offset == null ? null : offset.toString());
  return sb.toString();
}

Fixed version (ground truth):
@Override public String applySqlInlined(String sql,boolean isSubquery,Integer limit,Integer offset){
  if (limit == null && offset == null) {
    return sql;
  }
  StringBuilder sb=new StringBuilder(sql.length() + length);
  sb.append(sql);
  if (limitIncludesOffset() && offset != null && limit != null) {
    applySql(sb,isSubquery,Integer.toString(limit + offset),offset.toString());
  }
 else {
    applySql(sb,isSubquery,limit == null ? null : limit.toString(),offset == null ? null : offset.toString());
  }
  return sb.toString();
}
Program: 168897
Project: 168897
Buggy source:
@Override public String applySql(String sql,boolean isSubquery,Integer limit,Integer offset){
  if (limit == null && offset == null) {
    return sql;
  }
  StringBuilder sb=new StringBuilder(sql.length() + length);
  sb.append(sql);
  applySql(sb,isSubquery,limit == null ? null : "String_Node_Str",offset == null ? null : "String_Node_Str");
  return sb.toString();
}

Fixed version (ground truth):
@Override public String applySql(String sql,boolean isSubquery,Integer limit,Integer offset){
  if (limit == null && offset == null) {
    return sql;
  }
  StringBuilder sb=new StringBuilder(sql.length() + length);
  sb.append(sql);
  if (supportsVariableLimit()) {
    applySql(sb,isSubquery,limit == null ? null : "String_Node_Str",offset == null ? null : "String_Node_Str");
  }
 else {
    if (limitIncludesOffset() && offset != null && limit != null) {
      applySql(sb,isSubquery,Integer.toString(limit + offset),offset.toString());
    }
 else {
      applySql(sb,isSubquery,limit == null ? null : limit.toString(),offset == null ? null : offset.toString());
    }
  }
  return sb.toString();
}
Program: 168899
Project: 168899
Buggy source:
@Override public boolean supportsVariableLimit(){
  return false;
}

Fixed version (ground truth):
@Override public boolean supportsVariableLimit(){
  return true;
}
Program: 168900
Project: 168900
Buggy source:
protected void renderLimitOffset(FunctionRenderContext functionRenderContext){
  StringBuilder sqlSb=getSql(functionRenderContext);
  dbmsDialect.appendExtendedSql(sqlSb,DbmsStatementType.SELECT,true,false,null,functionRenderContext.getArgument(1),functionRenderContext.getArgument(2),null,null);
  functionRenderContext.addChunk(sqlSb.toString());
}

Fixed version (ground truth):
protected void renderLimitOffset(FunctionRenderContext functionRenderContext){
  StringBuilder sqlSb=getSql(functionRenderContext);
  if (limitIncludesOffset) {
    String limit=functionRenderContext.getArgument(1);
    String offset=functionRenderContext.getArgument(2);
    if (limit.contains("String_Node_Str") || offset.contains("String_Node_Str")) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    Integer limitValue=Integer.parseInt(limit);
    Integer offsetValue=Integer.parseInt(offset);
    dbmsDialect.appendExtendedSql(sqlSb,DbmsStatementType.SELECT,true,false,null,Integer.toString(limitValue + offsetValue),offset,null,null);
  }
 else {
    dbmsDialect.appendExtendedSql(sqlSb,DbmsStatementType.SELECT,true,false,null,functionRenderContext.getArgument(1),functionRenderContext.getArgument(2),null,null);
  }
  functionRenderContext.addChunk(sqlSb.toString());
}
Program: 168901
Project: 168901
Buggy source:
public LimitFunction(DbmsDialect dbmsDialect){
  this.dbmsDialect=dbmsDialect;
}

Fixed version (ground truth):
public LimitFunction(DbmsDialect dbmsDialect){
  this.dbmsDialect=dbmsDialect;
  this.limitIncludesOffset=dbmsDialect.createLimitHandler().limitIncludesOffset();
}
Program: 168903
Project: 168903
Buggy source:
@Test public void testSelectSizeAsDistinctCount2(){
  EntityTransaction tx=em.getTransaction();
  try {
    tx.begin();
    Document d=new Document("String_Node_Str");
    Person p1=new Person("String_Node_Str");
    Person p2=new Person("String_Node_Str");
    d.setOwner(p1);
    d.getPartners().add(p1);
    d.getPartners().add(p2);
    em.persist(p1);
    em.persist(p2);
    em.persist(d);
    Version v1=new Version();
    v1.setDate(Calendar.getInstance());
    v1.setDocument(d);
    Version v2=new Version();
    v2.setDate(Calendar.getInstance());
    v2.setDocument(d);
    Version v3=new Version();
    v3.setDate(Calendar.getInstance());
    v3.setDocument(d);
    em.persist(v1);
    em.persist(v2);
    em.persist(v3);
    tx.commit();
  }
 catch (  Throwable t) {
    t.printStackTrace();
    tx.rollback();
  }
  CriteriaBuilder<Tuple> cb=cbf.create(em,Tuple.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  String expected="String_Node_Str" + function("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str") + "String_Node_Str";
  assertEquals(expected,cb.getQueryString());
  List<Tuple> result=cb.getResultList();
  assertEquals(3l,result.get(0).get(0));
}

Fixed version (ground truth):
@Test public void testSelectSizeAsDistinctCount2(){
  EntityTransaction tx=em.getTransaction();
  try {
    tx.begin();
    Document d=new Document("String_Node_Str");
    Person p1=new Person("String_Node_Str");
    Person p2=new Person("String_Node_Str");
    d.setOwner(p1);
    d.getPartners().add(p1);
    d.getPartners().add(p2);
    em.persist(p1);
    em.persist(p2);
    em.persist(d);
    Version v1=new Version();
    v1.setDate(Calendar.getInstance());
    v1.setDocument(d);
    Version v2=new Version();
    v2.setDate(Calendar.getInstance());
    v2.setDocument(d);
    Version v3=new Version();
    v3.setDate(Calendar.getInstance());
    v3.setDocument(d);
    em.persist(v1);
    em.persist(v2);
    em.persist(v3);
    tx.commit();
  }
 catch (  Throwable t) {
    t.printStackTrace();
    tx.rollback();
  }
  CriteriaBuilder<Tuple> cb=cbf.create(em,Tuple.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  String expected="String_Node_Str" + function("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str") + "String_Node_Str";
  assertEquals(expected,cb.getQueryString());
  List<Tuple> result=cb.getResultList();
  assertEquals(3L,result.get(0).get(0));
}
Program: 168905
Project: 168905
Buggy source:
@Override public void render(FunctionRenderContext context){
  Count count=getCount(context);
  context.addChunk("String_Node_Str");
  if (count.isDistinct()) {
    context.addChunk(DISTINCT);
  }
  int argumentStartIndex=count.getArgumentStartIndex();
  if (context.getArgumentsSize() > 1) {
    context.addChunk("String_Node_Str");
    if (count.isDistinct()) {
      context.addArgument(argumentStartIndex);
      for (int i=argumentStartIndex + 1; i < context.getArgumentsSize(); i++) {
        context.addChunk("String_Node_Str");
        context.addArgument(i);
      }
    }
 else {
      context.addChunk("String_Node_Str");
      context.addArgument(argumentStartIndex);
      context.addChunk("String_Node_Str");
      for (int i=argumentStartIndex + 1; i < context.getArgumentsSize(); i++) {
        context.addChunk("String_Node_Str");
        context.addArgument(i);
        context.addChunk("String_Node_Str");
      }
      context.addChunk("String_Node_Str");
    }
    context.addChunk("String_Node_Str");
  }
 else {
    context.addArgument(argumentStartIndex);
  }
  context.addChunk("String_Node_Str");
}

Fixed version (ground truth):
@Override public void render(FunctionRenderContext context){
  Count count=getCount(context);
  context.addChunk("String_Node_Str");
  if (count.isDistinct()) {
    context.addChunk(DISTINCT);
  }
  int argumentStartIndex=count.getArgumentStartIndex();
  if (context.getArgumentsSize() > 1) {
    if (count.isDistinct()) {
      context.addArgument(argumentStartIndex);
      for (int i=argumentStartIndex + 1; i < context.getArgumentsSize(); i++) {
        context.addChunk("String_Node_Str");
        context.addArgument(i);
      }
    }
 else {
      context.addChunk("String_Node_Str");
      context.addArgument(argumentStartIndex);
      context.addChunk("String_Node_Str");
      for (int i=argumentStartIndex + 1; i < context.getArgumentsSize(); i++) {
        context.addChunk("String_Node_Str");
        context.addArgument(i);
        context.addChunk("String_Node_Str");
      }
      context.addChunk("String_Node_Str");
    }
  }
 else {
    context.addArgument(argumentStartIndex);
  }
  context.addChunk("String_Node_Str");
}
Program: 168907
Project: 168907
Buggy source:
public HibernateJpa21Provider(EntityManager em,String dbms,Map<String,CollectionPersister> collectionPersisters,int major,int minor,int fix){
  super(em,dbms,collectionPersisters);
  this.major=major;
  this.minor=minor;
  this.fix=fix;
}

Fixed version (ground truth):
public HibernateJpa21Provider(EntityManager em,String dbms,int major,int minor,int fix){
  super(em,dbms);
  this.major=major;
  this.minor=minor;
  this.fix=fix;
}
Program: 168908
Project: 168908
Buggy source:
public HibernateJpaProvider(EntityManager em,String dbms,Map<String,CollectionPersister> collectionPersisters){
  try {
    if (em == null) {
      db=DB.OTHER;
    }
 else     if ("String_Node_Str".equals(dbms)) {
      db=DB.MY_SQL;
    }
 else     if ("String_Node_Str".equals(dbms)) {
      db=DB.DB2;
    }
 else {
      db=DB.OTHER;
    }
    this.collectionPersisters=collectionPersisters;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public HibernateJpaProvider(EntityManager em,String dbms){
  try {
    if (em == null) {
      db=DB.OTHER;
    }
 else     if ("String_Node_Str".equals(dbms)) {
      db=DB.MY_SQL;
    }
 else     if ("String_Node_Str".equals(dbms)) {
      db=DB.DB2;
    }
 else {
      db=DB.OTHER;
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 168909
Project: 168909
Buggy source:
@Override public JpaProviderFactory getJpaProviderFactory(final EntityManagerFactory entityManagerFactory){
  if (major > 4 || major == 4 && minor >= 3) {
    return new JpaProviderFactory(){
      @Override public JpaProvider createJpaProvider(      EntityManager em){
        return new HibernateJpa21Provider(em,getDbms(entityManagerFactory),getCollectionPersisters(em),major,minor,fix);
      }
    }
;
  }
 else {
    return new JpaProviderFactory(){
      @Override public JpaProvider createJpaProvider(      EntityManager em){
        return new HibernateJpaProvider(em,getDbms(entityManagerFactory),getCollectionPersisters(em));
      }
    }
;
  }
}

Fixed version (ground truth):
@Override public JpaProviderFactory getJpaProviderFactory(final EntityManagerFactory entityManagerFactory){
  if (major > 4 || major == 4 && minor >= 3) {
    return new JpaProviderFactory(){
      @Override public JpaProvider createJpaProvider(      EntityManager em){
        return new HibernateJpa21Provider(em,getDbms(entityManagerFactory),major,minor,fix);
      }
    }
;
  }
 else {
    return new JpaProviderFactory(){
      @Override public JpaProvider createJpaProvider(      EntityManager em){
        return new HibernateJpaProvider(em,getDbms(entityManagerFactory));
      }
    }
;
  }
}
Program: 168910
Project: 168910
Buggy source:
@Override public JpaProvider createJpaProvider(EntityManager em){
  return new HibernateJpaProvider(em,getDbms(entityManagerFactory),getCollectionPersisters(em));
}

Fixed version (ground truth):
@Override public JpaProvider createJpaProvider(EntityManager em){
  return new HibernateJpaProvider(em,getDbms(entityManagerFactory));
}
Program: 168911
Project: 168911
Buggy source:
private void checkEntityId(Object entityId){
  if (entityId == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityType<?> entityType=em.getMetamodel().entity(joinManager.getRootNodeOrFail("String_Node_Str").getPropertyClass());
  Class<?> idType=entityType.getIdType().getJavaType();
  if (!idType.isInstance(entityId)) {
    throw new IllegalArgumentException("String_Node_Str" + entityId.getClass().getName() + "String_Node_Str"+ idType.getName()+ "String_Node_Str"+ entityType.getJavaType().getName()+ "String_Node_Str");
  }
}

Fixed version (ground truth):
private void checkEntityId(Object entityId){
  if (entityId == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  EntityType<?> entityType=em.getMetamodel().entity(joinManager.getRootNodeOrFail("String_Node_Str").getPropertyClass());
  Attribute<?,?> idAttribute=JpaUtils.getIdAttribute(entityType);
  Class<?> idType=JpaUtils.resolveFieldClass(entityType.getJavaType(),idAttribute);
  if (!idType.isInstance(entityId)) {
    throw new IllegalArgumentException("String_Node_Str" + entityId.getClass().getName() + "String_Node_Str"+ idType.getName()+ "String_Node_Str"+ entityType.getJavaType().getName()+ "String_Node_Str");
  }
}
Program: 168912
Project: 168912
Buggy source:
private boolean applyCascadingDelete(Query baseQuery,AbstractCommonQueryBuilder<?,?,?,?,?> queryBuilder,List<Query> participatingQueries,StringBuilder sb,String cteBaseName,boolean firstCte){
  if (queryBuilder.statementType == DbmsStatementType.DELETE) {
    List<String> cascadingDeleteSqls=cbf.getExtendedQuerySupport().getCascadingDeleteSql(em,baseQuery);
    StringBuilder cascadingDeleteSqlSb=new StringBuilder();
    int cteBaseNameCount=0;
    for (    String cascadingDeleteSql : cascadingDeleteSqls) {
      if (firstCte) {
        firstCte=false;
      }
 else {
        sb.append("String_Node_Str");
      }
      participatingQueries.add(baseQuery);
      sb.append(cteBaseName);
      sb.append('_').append(cteBaseNameCount);
      sb.append("String_Node_Str");
      cascadingDeleteSqlSb.setLength(0);
      cascadingDeleteSqlSb.append(cascadingDeleteSql);
      dbmsDialect.appendExtendedSql(cascadingDeleteSqlSb,DbmsStatementType.DELETE,false,true,null,null,null,null,null);
      sb.append(cascadingDeleteSqlSb);
      sb.append("String_Node_Str");
    }
  }
  return firstCte;
}

Fixed version (ground truth):
private boolean applyCascadingDelete(Query baseQuery,AbstractCommonQueryBuilder<?,?,?,?,?> queryBuilder,List<Query> participatingQueries,StringBuilder sb,String cteBaseName,boolean firstCte){
  if (queryBuilder.statementType == DbmsStatementType.DELETE) {
    List<String> cascadingDeleteSqls=cbf.getExtendedQuerySupport().getCascadingDeleteSql(em,baseQuery);
    StringBuilder cascadingDeleteSqlSb=new StringBuilder();
    int cteBaseNameCount=0;
    for (    String cascadingDeleteSql : cascadingDeleteSqls) {
      if (firstCte) {
        firstCte=false;
      }
 else {
        sb.append("String_Node_Str");
      }
      participatingQueries.add(baseQuery);
      sb.append(cteBaseName);
      sb.append('_').append(cteBaseNameCount++);
      sb.append("String_Node_Str");
      cascadingDeleteSqlSb.setLength(0);
      cascadingDeleteSqlSb.append(cascadingDeleteSql);
      dbmsDialect.appendExtendedSql(cascadingDeleteSqlSb,DbmsStatementType.DELETE,false,true,null,null,null,null,null);
      sb.append(cascadingDeleteSqlSb);
      sb.append("String_Node_Str");
    }
  }
  return firstCte;
}
Program: 168913
Project: 168913
Buggy source:
@Override public Expression visitConditional_factor(JPQLSelectExpressionParser.Conditional_factorContext ctx){
  Predicate p=(Predicate)ctx.conditional_primary().accept(this);
  if (ctx.not != null) {
    if (p instanceof Negatable) {
      ((Negatable)p).setNegated(true);
    }
 else {
      p=new NotPredicate(p);
    }
  }
  return p;
}

Fixed version (ground truth):
@Override public Expression visitConditional_factor(JPQLSelectExpressionParser.Conditional_factorContext ctx){
  Predicate p=(Predicate)ctx.conditional_primary().accept(this);
  if (ctx.not != null) {
    if (p instanceof Negatable) {
      Negatable n=(Negatable)p;
      n.setNegated(!n.isNegated());
    }
 else {
      p=new NotPredicate(p);
    }
  }
  return p;
}
Program: 168914
Project: 168914
Buggy source:
public Object getParameterValue(String name){
  return parameterManager.getParameterValue(name);
}

Fixed version (ground truth):
public Object getParameterValue(String name){
  Object paramValue=parameterManager.getParameterValue(name);
  if (paramValue instanceof ParameterManager.TemporalCalendarParameterWrapper) {
    ParameterManager.TemporalCalendarParameterWrapper wrappedValue=(ParameterManager.TemporalCalendarParameterWrapper)paramValue;
    return wrappedValue.getValue();
  }
 else   if (paramValue instanceof ParameterManager.TemporalDateParameterWrapper) {
    ParameterManager.TemporalDateParameterWrapper wrappedValue=(ParameterManager.TemporalDateParameterWrapper)paramValue;
    return wrappedValue.getValue();
  }
 else {
    return paramValue;
  }
}
Program: 168915
Project: 168915
Buggy source:
@Override public Expression transform(Expression original,ClauseType fromClause,boolean joinRequired){
  if (original instanceof PathExpression) {
    PathExpression originalPathExpr=(PathExpression)original;
    if (originalPathExpr.toString().equals(alias)) {
      return substitute;
    }
  }
  return original;
}

Fixed version (ground truth):
@Override public Expression transform(Expression original,ClauseType fromClause,boolean joinRequired){
  if (original instanceof PathExpression) {
    PathExpression originalPathExpr=(PathExpression)original;
    if (originalPathExpr.toString().equals(alias)) {
      return substitute;
    }
  }
 else   if (original instanceof QuantifierExpression) {
    QuantifierExpression originalQuantifierExpr=(QuantifierExpression)original;
    if (originalQuantifierExpr.getExpression().toString().equals(alias)) {
      return substitute;
    }
  }
 else   if (original instanceof FooExpression) {
    FooExpression originalQuantifierExpr=(FooExpression)original;
    if (originalQuantifierExpr.toString().equals(alias)) {
      return substitute;
    }
  }
  return original;
}
Program: 168917
Project: 168917
Buggy source:
@OneToMany @JoinTable(name="String_Node_Str") @MapKeyColumn(table="String_Node_Str",nullable=false) public Map<String,PolymorphicBase> getMap(){
  return map;
}

Fixed version (ground truth):
@OneToMany @JoinTable(name="String_Node_Str") @MapKeyColumn(table="String_Node_Str",nullable=false,length=20) public Map<String,PolymorphicBase> getMap(){
  return map;
}
Program: 168918
Project: 168918
Buggy source:
@Test public void testMultipleCorrelationsWithJoins(){
  CriteriaBuilder<Document> crit=cbf.create(em,Document.class,"String_Node_Str").where("String_Node_Str").in().from("String_Node_Str","String_Node_Str").from("String_Node_Str","String_Node_Str").from("String_Node_Str","String_Node_Str").select("String_Node_Str").leftJoin("String_Node_Str","String_Node_Str").leftJoin("String_Node_Str","String_Node_Str").leftJoin("String_Node_Str","String_Node_Str").where("String_Node_Str").eqExpression("String_Node_Str").end();
  String expectedQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(expectedQuery,crit.getQueryString());
  crit.getResultList();
}

Fixed version (ground truth):
@Test @Category({NoDatanucleus.class}) public void testMultipleCorrelationsWithJoins(){
  CriteriaBuilder<Document> crit=cbf.create(em,Document.class,"String_Node_Str").where("String_Node_Str").in().from("String_Node_Str","String_Node_Str").from("String_Node_Str","String_Node_Str").from("String_Node_Str","String_Node_Str").select("String_Node_Str").leftJoin("String_Node_Str","String_Node_Str").leftJoin("String_Node_Str","String_Node_Str").leftJoin("String_Node_Str","String_Node_Str").where("String_Node_Str").eqExpression("String_Node_Str").end();
  String expectedQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertEquals(expectedQuery,crit.getQueryString());
  crit.getResultList();
}
Program: 168919
Project: 168919
Buggy source:
@Test public void testSubqueryCorrelatesSimple(){
  CriteriaBuilder<Document> crit=cbf.create(em,Document.class,"String_Node_Str").where("String_Node_Str").in().from("String_Node_Str").where("String_Node_Str").eqExpression("String_Node_Str").end();
  String expectedQuery="String_Node_Str";
  assertEquals(expectedQuery,crit.getQueryString());
  crit.getResultList();
}

Fixed version (ground truth):
@Test @Category({NoDatanucleus.class}) public void testSubqueryCorrelatesSimple(){
  CriteriaBuilder<Document> crit=cbf.create(em,Document.class,"String_Node_Str").where("String_Node_Str").in().from("String_Node_Str").where("String_Node_Str").eqExpression("String_Node_Str").end();
  String expectedQuery="String_Node_Str";
  assertEquals(expectedQuery,crit.getQueryString());
  crit.getResultList();
}
Program: 168921
Project: 168921
Buggy source:
/** 
 * Builds the clauses needed for the group by clause for a query that uses aggregate functions to work.
 * @return
 */
void buildGroupByClauses(Set<String> clauses){
  if (orderByInfos.isEmpty()) {
    return;
  }
  boolean conditionalContext=queryGenerator.setConditionalContext(false);
  StringBuilder sb=new StringBuilder();
  List<OrderByInfo> infos=orderByInfos;
  int size=infos.size();
  for (int i=0; i < size; i++) {
    final OrderByInfo orderByInfo=infos.get(i);
    String potentialSelectAlias=orderByInfo.getExpression().toString();
    AliasInfo aliasInfo=aliasManager.getAliasInfo(potentialSelectAlias);
    Expression expr;
    if (aliasInfo != null && aliasInfo instanceof SelectInfo) {
      SelectInfo selectInfo=(SelectInfo)aliasInfo;
      expr=selectInfo.getExpression();
    }
 else {
      expr=orderByInfo.getExpression();
    }
    GroupByUsableDetectionVisitor groupByUsableDetectionVisitor=new GroupByUsableDetectionVisitor();
    if (!expr.accept(groupByUsableDetectionVisitor)) {
      sb.setLength(0);
      queryGenerator.setQueryBuffer(sb);
      expr.accept(queryGenerator);
      clauses.add(sb.toString());
    }
  }
  queryGenerator.setConditionalContext(conditionalContext);
}

Fixed version (ground truth):
/** 
 * Builds the clauses needed for the group by clause for a query that uses aggregate functions to work.
 * @return
 */
void buildGroupByClauses(Set<String> clauses){
  if (orderByInfos.isEmpty()) {
    return;
  }
  boolean conditionalContext=queryGenerator.setConditionalContext(false);
  StringBuilder sb=new StringBuilder();
  List<OrderByInfo> infos=orderByInfos;
  int size=infos.size();
  for (int i=0; i < size; i++) {
    final OrderByInfo orderByInfo=infos.get(i);
    String potentialSelectAlias=orderByInfo.getExpression().toString();
    AliasInfo aliasInfo=aliasManager.getAliasInfo(potentialSelectAlias);
    Expression expr;
    if (aliasInfo != null && aliasInfo instanceof SelectInfo) {
      SelectInfo selectInfo=(SelectInfo)aliasInfo;
      expr=selectInfo.getExpression();
    }
 else {
      expr=orderByInfo.getExpression();
    }
    GroupByUsableDetectionVisitor groupByUsableDetectionVisitor=new GroupByUsableDetectionVisitor(false);
    if (!expr.accept(groupByUsableDetectionVisitor)) {
      sb.setLength(0);
      queryGenerator.setQueryBuffer(sb);
      expr.accept(queryGenerator);
      clauses.add(sb.toString());
    }
  }
  queryGenerator.setConditionalContext(conditionalContext);
}
Program: 168922
Project: 168922
Buggy source:
/** 
 * @return an array with length 2. Element 0 is true if the select clause contains a any expression that would be required in group by when aggregates are used. Element 1 is true if the select clause contains a any complex expression that would be required in group by when aggregates are used.
 */
public boolean[] containsGroupBySelect(){
  GroupByExpressionGatheringVisitor gatheringVisitor=new GroupByExpressionGatheringVisitor();
  boolean containsGroupBySelect=false;
  for (  SelectInfo selectInfo : selectInfos) {
    if (!(selectInfo.getExpression() instanceof PathExpression)) {
      selectInfo.getExpression().accept(gatheringVisitor);
    }
 else {
      containsGroupBySelect=true;
    }
  }
  boolean containsComplexGroupBySelect=!gatheringVisitor.getExpressions().isEmpty();
  return new boolean[]{containsGroupBySelect || containsComplexGroupBySelect,containsComplexGroupBySelect};
}

Fixed version (ground truth):
/** 
 * @return an array with length 2. Element 0 is true if the select clause contains a any expression that would be required in group by when aggregates are used. Element 1 is true if the select clause contains a any complex expression that would be required in group by when aggregates are used.
 */
public boolean[] containsGroupBySelect(boolean treatSizeAsAggregate){
  GroupByExpressionGatheringVisitor gatheringVisitor=new GroupByExpressionGatheringVisitor(treatSizeAsAggregate);
  boolean containsGroupBySelect=false;
  for (  SelectInfo selectInfo : selectInfos) {
    if (!(selectInfo.getExpression() instanceof PathExpression)) {
      selectInfo.getExpression().accept(gatheringVisitor);
    }
 else {
      containsGroupBySelect=true;
    }
  }
  boolean containsComplexGroupBySelect=!gatheringVisitor.getExpressions().isEmpty();
  return new boolean[]{containsGroupBySelect || containsComplexGroupBySelect,containsComplexGroupBySelect};
}
Program: 168923
Project: 168923
Buggy source:
@Override public Expression transform(Expression original,ClauseType fromClause,boolean joinRequired){
  if (fromClause != ClauseType.SELECT) {
    sizeTransformationVisitor.setClause(fromClause);
    sizeTransformationVisitor.setOrderBySelectClause(false);
    boolean[] groupBySelectStatus=selectManager.containsGroupBySelect();
    sizeTransformationVisitor.setHasGroupBySelects(groupBySelectStatus[0]);
    sizeTransformationVisitor.setHasComplexGroupBySelects(groupBySelectStatus[1]);
    return original.accept(sizeTransformationVisitor);
  }
 else {
    return original;
  }
}

Fixed version (ground truth):
@Override public Expression transform(Expression original,ClauseType fromClause,boolean joinRequired){
  if (fromClause != ClauseType.SELECT) {
    sizeTransformationVisitor.setClause(fromClause);
    sizeTransformationVisitor.setOrderBySelectClause(false);
    boolean[] groupBySelectStatus=selectManager.containsGroupBySelect(true);
    sizeTransformationVisitor.setHasGroupBySelects(groupBySelectStatus[0]);
    sizeTransformationVisitor.setHasComplexGroupBySelects(groupBySelectStatus[1]);
    return original.accept(sizeTransformationVisitor);
  }
 else {
    return original;
  }
}
Program: 168924
Project: 168924
Buggy source:
@Override public void transform(SelectInfo info){
  sizeTransformationVisitor.setOrderBySelectClause(orderByManager.getOrderBySelectAliases().contains(info.getAlias()));
  sizeTransformationVisitor.setClause(ClauseType.SELECT);
  boolean[] groupBySelectStatus=selectManager.containsGroupBySelect();
  sizeTransformationVisitor.setHasGroupBySelects(groupBySelectStatus[0]);
  sizeTransformationVisitor.setHasComplexGroupBySelects(groupBySelectStatus[1]);
  if (ExpressionUtils.isSizeFunction(info.getExpression())) {
    info.setExpression(info.getExpression().accept(sizeTransformationVisitor));
  }
 else {
    info.getExpression().accept(sizeTransformationVisitor);
  }
}

Fixed version (ground truth):
@Override public void transform(SelectInfo info){
  sizeTransformationVisitor.setOrderBySelectClause(orderByManager.getOrderBySelectAliases().contains(info.getAlias()));
  sizeTransformationVisitor.setClause(ClauseType.SELECT);
  boolean[] groupBySelectStatus=selectManager.containsGroupBySelect(true);
  sizeTransformationVisitor.setHasGroupBySelects(groupBySelectStatus[0]);
  sizeTransformationVisitor.setHasComplexGroupBySelects(groupBySelectStatus[1]);
  if (ExpressionUtils.isSizeFunction(info.getExpression())) {
    info.setExpression(info.getExpression().accept(sizeTransformationVisitor));
  }
 else {
    info.getExpression().accept(sizeTransformationVisitor);
  }
}
Program: 168928
Project: 168928
Buggy source:
private List<List<Attribute<?,?>>> getAndCheckAttributes(String[] attributes){
  List<List<Attribute<?,?>>> attrs=new ArrayList<List<Attribute<?,?>>>(attributes.length);
  for (int i=0; i < attributes.length; i++) {
    if (attributes[i] == null) {
      throw new NullPointerException("String_Node_Str" + i);
    }
    if (attributes[i].isEmpty()) {
      throw new IllegalArgumentException("String_Node_Str" + i);
    }
    attrs.add(getAndCheckAttributePath(attributes[i]));
  }
  return attrs;
}

Fixed version (ground truth):
private List<List<Attribute<?,?>>> getAndCheckAttributes(String[] attributes){
  List<List<Attribute<?,?>>> attrs=new ArrayList<List<Attribute<?,?>>>(attributes.length);
  for (int i=0; i < attributes.length; i++) {
    if (attributes[i] == null) {
      throw new NullPointerException("String_Node_Str" + i);
    }
    if (attributes[i].isEmpty()) {
      throw new IllegalArgumentException("String_Node_Str" + i);
    }
    attrs.add(JpaUtils.getBasicAttributePath(getMetamodel(),entityType,attributes[i]));
  }
  return attrs;
}
Program: 168929
Project: 168929
Buggy source:
@Override public SelectBuilder<X> bind(String attributeName){
  entityType.getAttribute(attributeName);
  Integer attributeBindIndex=bindingMap.get(attributeName);
  if (attributeBindIndex != null) {
    throw new IllegalArgumentException("String_Node_Str" + attributeName + "String_Node_Str");
  }
  bindingMap.put(attributeName,selectManager.getSelectInfos().size());
  return this;
}

Fixed version (ground truth):
@Override public SelectBuilder<X> bind(String attributeName){
  if (entityType.getAttribute(attributeName) == null) {
    throw new IllegalArgumentException("String_Node_Str" + attributeName + "String_Node_Str"+ entityType.getName()+ "String_Node_Str");
  }
  Integer attributeBindIndex=bindingMap.get(attributeName);
  if (attributeBindIndex != null) {
    throw new IllegalArgumentException("String_Node_Str" + attributeName + "String_Node_Str");
  }
  bindingMap.put(attributeName,selectManager.getSelectInfos().size());
  return this;
}
Program: 168930
Project: 168930
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public X set(String attributeName,Object value){
  entityType.getAttribute(attributeName);
  String attributeValue=setAttributes.get(attributeName);
  if (attributeValue != null) {
    throw new IllegalArgumentException("String_Node_Str" + attributeName + "String_Node_Str");
  }
  String paramName=parameterManager.addParameter(value);
  setAttributes.put(attributeName,paramName);
  return (X)this;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public X set(String attributeName,Object value){
  JpaUtils.getBasicAttributePath(getMetamodel(),entityType,attributeName);
  String attributeValue=setAttributes.get(attributeName);
  if (attributeValue != null) {
    throw new IllegalArgumentException("String_Node_Str" + attributeName + "String_Node_Str");
  }
  String paramName=parameterManager.addParameter(value);
  setAttributes.put(attributeName,paramName);
  return (X)this;
}
Program: 168931
Project: 168931
Buggy source:
@Test @Category({NoHibernate.class}) public void testBuggyHqlIn(){
  CriteriaBuilder<Document> criteria=cbf.create(em,Document.class,"String_Node_Str");
  List<Integer> indicies=Arrays.asList(new Integer[]{1,2,3,4,5});
  criteria.where("String_Node_Str").eqExpression("String_Node_Str").whereOr().where("String_Node_Str").eqExpression("String_Node_Str").where("String_Node_Str").in(indicies).endOr();
  assertEquals("String_Node_Str",criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test @Category({NoHibernate.class}) public void testBuggyHqlIn(){
  CriteriaBuilder<Document> criteria=cbf.create(em,Document.class,"String_Node_Str");
  List<Integer> indicies=Arrays.asList(new Integer[]{1,2,3,4,5});
  criteria.where("String_Node_Str").eqExpression("String_Node_Str").whereOr().where("String_Node_Str").eqExpression("String_Node_Str").where("String_Node_Str").in(indicies).endOr();
  assertEquals("String_Node_Str" + listParameter("String_Node_Str") + "String_Node_Str",criteria.getQueryString());
  criteria.getResultList();
}
Program: 168932
Project: 168932
Buggy source:
@Test @Category({NoHibernate.class}) public void testBuggyHqlIn1(){
  CriteriaBuilder<Document> criteria=cbf.create(em,Document.class,"String_Node_Str");
  List<Integer> indicies=Arrays.asList(new Integer[]{1,2,3,4,5});
  criteria.whereOr().where("String_Node_Str").eqExpression("String_Node_Str").whereAnd().where("String_Node_Str").eqExpression("String_Node_Str").where("String_Node_Str").in(indicies).endAnd().endOr();
  assertEquals("String_Node_Str",criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test @Category({NoHibernate.class}) public void testBuggyHqlIn1(){
  CriteriaBuilder<Document> criteria=cbf.create(em,Document.class,"String_Node_Str");
  List<Integer> indicies=Arrays.asList(new Integer[]{1,2,3,4,5});
  criteria.whereOr().where("String_Node_Str").eqExpression("String_Node_Str").whereAnd().where("String_Node_Str").eqExpression("String_Node_Str").where("String_Node_Str").in(indicies).endAnd().endOr();
  assertEquals("String_Node_Str" + listParameter("String_Node_Str") + "String_Node_Str",criteria.getQueryString());
  criteria.getResultList();
}
Program: 168934
Project: 168934
Buggy source:
@Test @Category({NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class,NoMySQL.class}) public void testSubqueryOrderByLimit(){
  CriteriaBuilder<String> cb=cbf.create(em,String.class).from(Document.class,"String_Node_Str").select("String_Node_Str").where("String_Node_Str").in().from(Document.class,"String_Node_Str").select("String_Node_Str","String_Node_Str").where("String_Node_Str").eq("String_Node_Str").union().from(Document.class,"String_Node_Str").select("String_Node_Str").where("String_Node_Str").eq("String_Node_Str").startExcept().from(Document.class,"String_Node_Str").select("String_Node_Str","String_Node_Str").where("String_Node_Str").eq("String_Node_Str").union().from(Document.class,"String_Node_Str").select("String_Node_Str").where("String_Node_Str").eq("String_Node_Str").endSetWith().orderByDesc("String_Node_Str").setMaxResults(1).endSet().endSet().orderByDesc("String_Node_Str").setMaxResults(1).end();
  String expected="String_Node_Str" + "String_Node_Str" + function("String_Node_Str",function("String_Node_Str","String_Node_Str","String_Node_Str"),function("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str") + "String_Node_Str";
  assertEquals(expected,cb.getQueryString());
  List<String> resultList=cb.getResultList();
  assertEquals(1,resultList.size());
  assertEquals("String_Node_Str",resultList.get(0));
}

Fixed version (ground truth):
@Test @Category({NoH2.class,NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class,NoMySQL.class}) public void testSubqueryOrderByLimit(){
  CriteriaBuilder<String> cb=cbf.create(em,String.class).from(Document.class,"String_Node_Str").select("String_Node_Str").where("String_Node_Str").in().from(Document.class,"String_Node_Str").select("String_Node_Str","String_Node_Str").where("String_Node_Str").eq("String_Node_Str").union().from(Document.class,"String_Node_Str").select("String_Node_Str").where("String_Node_Str").eq("String_Node_Str").startExcept().from(Document.class,"String_Node_Str").select("String_Node_Str","String_Node_Str").where("String_Node_Str").eq("String_Node_Str").union().from(Document.class,"String_Node_Str").select("String_Node_Str").where("String_Node_Str").eq("String_Node_Str").endSetWith().orderByDesc("String_Node_Str").setMaxResults(1).endSet().endSet().orderByDesc("String_Node_Str").setMaxResults(1).end();
  String expected="String_Node_Str" + "String_Node_Str" + function("String_Node_Str",function("String_Node_Str","String_Node_Str","String_Node_Str"),function("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str") + "String_Node_Str";
  assertEquals(expected,cb.getQueryString());
  List<String> resultList=cb.getResultList();
  assertEquals(1,resultList.size());
  assertEquals("String_Node_Str",resultList.get(0));
}
Program: 168935
Project: 168935
Buggy source:
@SuppressWarnings("String_Node_Str") public AbstractModificationCriteriaBuilder(MainQuery mainQuery,boolean isMainQuery,DbmsStatementType statementType,Class<T> clazz,String alias,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(mainQuery,isMainQuery,statementType,(Class<T>)Tuple.class,null);
  this.entityType=em.getMetamodel().entity(clazz);
  this.entityAlias=alias;
  this.result=result;
  this.listener=listener;
  if (cteClass == null) {
    this.cteType=null;
    this.cteName=null;
    this.isReturningEntityAliasAllowed=false;
    this.returningAttributeBindingMap=new LinkedHashMap<String,String>(0);
  }
 else {
    this.cteType=em.getMetamodel().entity(cteClass);
    this.cteName=cteType.getName();
    this.isReturningEntityAliasAllowed=true;
    this.returningAttributeBindingMap=new LinkedHashMap<String,String>(cteType.getAttributes().size());
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public AbstractModificationCriteriaBuilder(MainQuery mainQuery,boolean isMainQuery,DbmsStatementType statementType,Class<T> clazz,String alias,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(mainQuery,isMainQuery,statementType,(Class<T>)Tuple.class,null);
  if (alias == null) {
    alias=clazz.getSimpleName().toLowerCase();
  }
 else {
    fromClassExplicitelySet=true;
  }
  this.entityType=em.getMetamodel().entity(clazz);
  this.entityAlias=joinManager.addRoot(entityType,alias);
  this.result=result;
  this.listener=listener;
  if (cteClass == null) {
    this.cteType=null;
    this.cteName=null;
    this.isReturningEntityAliasAllowed=false;
    this.returningAttributeBindingMap=new LinkedHashMap<String,String>(0);
  }
 else {
    this.cteType=em.getMetamodel().entity(cteClass);
    this.cteName=cteType.getName();
    this.isReturningEntityAliasAllowed=true;
    this.returningAttributeBindingMap=new LinkedHashMap<String,String>(cteType.getAttributes().size());
  }
}
Program: 168936
Project: 168936
Buggy source:
@Override protected void getQueryString1(StringBuilder sbSelectFrom){
  sbSelectFrom.append("String_Node_Str");
  sbSelectFrom.append(entityType.getName()).append(' ');
  if (entityAlias != null) {
    sbSelectFrom.append(entityAlias);
  }
  appendWhereClause(sbSelectFrom);
}

Fixed version (ground truth):
@Override protected void getQueryString1(StringBuilder sbSelectFrom){
  sbSelectFrom.append("String_Node_Str");
  sbSelectFrom.append(entityType.getName()).append(' ');
  sbSelectFrom.append(entityAlias);
  appendWhereClause(sbSelectFrom);
}
Program: 168937
Project: 168937
Buggy source:
public BaseDeleteCriteriaBuilderImpl(MainQuery mainQuery,boolean isMainQuery,Class<T> clazz,String alias,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(mainQuery,isMainQuery,DbmsStatementType.DELETE,clazz,alias,cteClass,result,listener);
  if (alias == null) {
    alias=clazz.getSimpleName().toLowerCase();
  }
 else {
    fromClassExplicitelySet=true;
  }
  try {
    this.joinManager.addRoot(em.getMetamodel().entity(clazz),alias);
  }
 catch (  IllegalArgumentException ex) {
    throw new IllegalArgumentException("String_Node_Str" + clazz.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
public BaseDeleteCriteriaBuilderImpl(MainQuery mainQuery,boolean isMainQuery,Class<T> clazz,String alias,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(mainQuery,isMainQuery,DbmsStatementType.DELETE,clazz,alias,cteClass,result,listener);
}
Program: 168938
Project: 168938
Buggy source:
@Override protected void getQueryString1(StringBuilder sbSelectFrom){
  sbSelectFrom.append("String_Node_Str");
  sbSelectFrom.append(entityType.getName()).append(' ');
  if (entityAlias != null) {
    sbSelectFrom.append(entityAlias);
  }
  sbSelectFrom.append("String_Node_Str");
  for (  Map.Entry<String,String> attributeEntry : setAttributes.entrySet()) {
    sbSelectFrom.append(attributeEntry.getKey());
    sbSelectFrom.append("String_Node_Str");
    sbSelectFrom.append(attributeEntry.getValue());
  }
  appendWhereClause(sbSelectFrom);
}

Fixed version (ground truth):
@Override protected void getQueryString1(StringBuilder sbSelectFrom){
  sbSelectFrom.append("String_Node_Str");
  sbSelectFrom.append(entityType.getName()).append(' ');
  sbSelectFrom.append(entityAlias);
  sbSelectFrom.append("String_Node_Str");
  for (  Map.Entry<String,String> attributeEntry : setAttributes.entrySet()) {
    sbSelectFrom.append(attributeEntry.getKey());
    sbSelectFrom.append("String_Node_Str");
    sbSelectFrom.append(attributeEntry.getValue());
  }
  appendWhereClause(sbSelectFrom);
}
Program: 168939
Project: 168939
Buggy source:
public BaseUpdateCriteriaBuilderImpl(MainQuery mainQuery,boolean isMainQuery,Class<T> clazz,String alias,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(mainQuery,isMainQuery,DbmsStatementType.UPDATE,clazz,alias,cteClass,result,listener);
  if (alias == null) {
    alias=clazz.getSimpleName().toLowerCase();
  }
 else {
    fromClassExplicitelySet=true;
  }
  try {
    this.joinManager.addRoot(em.getMetamodel().entity(clazz),alias);
  }
 catch (  IllegalArgumentException ex) {
    throw new IllegalArgumentException("String_Node_Str" + clazz.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
public BaseUpdateCriteriaBuilderImpl(MainQuery mainQuery,boolean isMainQuery,Class<T> clazz,String alias,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(mainQuery,isMainQuery,DbmsStatementType.UPDATE,clazz,alias,cteClass,result,listener);
}
Program: 168940
Project: 168940
Buggy source:
public HibernateJpaProvider(EntityManager em){
  try {
    if (em == null) {
      db=DB.OTHER;
    }
 else {
      Object session=em.unwrap(Class.forName("String_Node_Str"));
      Class<?> dialectClass=ExpressionUtils.getValue(session,"String_Node_Str").getClass();
      WeakReference<Class<?>> key=new WeakReference<Class<?>>(dialectClass);
      DB cacheValue=dbDialectCache.get(key);
      if (cacheValue == null) {
        Set<Class<?>> types=ReflectionUtils.getSuperTypes(dialectClass);
        if (types.contains(Class.forName("String_Node_Str"))) {
          cacheValue=DB.MY_SQL;
        }
 else         if (types.contains(Class.forName("String_Node_Str"))) {
          cacheValue=DB.DB2;
        }
 else {
          cacheValue=DB.OTHER;
        }
        dbDialectCache.put(key,cacheValue);
      }
      db=cacheValue;
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public HibernateJpaProvider(EntityManager em){
  try {
    if (em == null) {
      db=DB.OTHER;
    }
 else {
      Object session=em.unwrap(Class.forName("String_Node_Str"));
      Class<?> dialectClass=ExpressionUtils.getValue(session,"String_Node_Str").getClass();
      WeakClassKey key=new WeakClassKey(dialectClass);
      DB cacheValue=dbDialectCache.get(key);
      if (cacheValue == null) {
        Set<Class<?>> types=ReflectionUtils.getSuperTypes(dialectClass);
        if (types.contains(Class.forName("String_Node_Str"))) {
          cacheValue=DB.MY_SQL;
        }
 else         if (types.contains(Class.forName("String_Node_Str"))) {
          cacheValue=DB.DB2;
        }
 else {
          cacheValue=DB.OTHER;
        }
        for (        WeakClassKey keyElement : dbDialectCache.keySet()) {
          if (keyElement.get() == null) {
            dbDialectCache.remove(keyElement);
          }
        }
        dbDialectCache.put(key,cacheValue);
      }
      db=cacheValue;
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 168941
Project: 168941
Buggy source:
public AbstractCTECriteriaBuilder(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,null,registeredFunctions);
  this.result=result;
  this.listener=listener;
  this.cteType=em.getMetamodel().entity(clazz);
  this.cteName=cteType.getName();
  this.bindingMap=new LinkedHashMap<String,Integer>();
}

Fixed version (ground truth):
public AbstractCTECriteriaBuilder(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,ParameterManager parameterManager,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,null,registeredFunctions,parameterManager);
  this.result=result;
  this.listener=listener;
  this.cteType=em.getMetamodel().entity(clazz);
  this.cteName=cteType.getName();
  this.bindingMap=new LinkedHashMap<String,Integer>();
}