nus-yam/ex-repair huggingface dataset:
Program: 168942
Project: 168942
Buggy source:
protected void applyImplicitJoins(){
  if (implicitJoinsApplied) {
    return;
  }
  final JoinVisitor joinVisitor=new JoinVisitor(joinManager);
  final JoinNodeVisitor joinNodeVisitor=new OnClauseJoinNodeVisitor(joinVisitor){
    @Override public void visit(    JoinNode node){
      super.visit(node);
      node.registerDependencies();
    }
  }
;
  joinVisitor.setFromClause(null);
  joinManager.acceptVisitor(joinNodeVisitor);
  joinVisitor.setFromClause(ClauseType.SELECT);
  selectManager.acceptVisitor(joinVisitor);
  joinVisitor.setFromClause(ClauseType.WHERE);
  whereManager.acceptVisitor(joinVisitor);
  joinVisitor.setFromClause(ClauseType.GROUP_BY);
  groupByManager.acceptVisitor(joinVisitor);
  joinVisitor.setFromClause(ClauseType.HAVING);
  havingManager.acceptVisitor(joinVisitor);
  joinVisitor.setJoinWithObjectLeafAllowed(false);
  joinVisitor.setFromClause(ClauseType.ORDER_BY);
  orderByManager.acceptVisitor(joinVisitor);
  joinVisitor.setJoinWithObjectLeafAllowed(true);
  implicitJoinsApplied=true;
}

Fixed version (ground truth):
protected void applyImplicitJoins(){
  if (implicitJoinsApplied) {
    return;
  }
  final JoinVisitor joinVisitor=new JoinVisitor(joinManager);
  final JoinNodeVisitor joinNodeVisitor=new OnClauseJoinNodeVisitor(joinVisitor){
    @Override public void visit(    JoinNode node){
      super.visit(node);
      node.registerDependencies();
    }
  }
;
  joinVisitor.setFromClause(null);
  joinManager.acceptVisitor(joinNodeVisitor);
  joinVisitor.setFromClause(ClauseType.SELECT);
  joinVisitor.setJoinRequired(isJoinRequiredForSelect());
  selectManager.acceptVisitor(joinVisitor);
  joinVisitor.setJoinRequired(true);
  joinVisitor.setFromClause(ClauseType.WHERE);
  whereManager.acceptVisitor(joinVisitor);
  joinVisitor.setFromClause(ClauseType.GROUP_BY);
  groupByManager.acceptVisitor(joinVisitor);
  joinVisitor.setFromClause(ClauseType.HAVING);
  havingManager.acceptVisitor(joinVisitor);
  joinVisitor.setJoinWithObjectLeafAllowed(false);
  joinVisitor.setFromClause(ClauseType.ORDER_BY);
  orderByManager.acceptVisitor(joinVisitor);
  joinVisitor.setJoinWithObjectLeafAllowed(true);
  implicitJoinsApplied=true;
}
Program: 168943
Project: 168943
Buggy source:
@SuppressWarnings("String_Node_Str") public AbstractModificationCriteriaBuilder(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,(Class<T>)Tuple.class,null,registeredFunctions);
  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.returningAttributeBindingMap=new LinkedHashMap<String,String>(0);
  }
 else {
    this.cteType=em.getMetamodel().entity(cteClass);
    this.cteName=cteType.getName();
    this.returningAttributeBindingMap=new LinkedHashMap<String,String>(cteType.getAttributes().size());
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public AbstractModificationCriteriaBuilder(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions,ParameterManager parameterManager,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,(Class<T>)Tuple.class,null,registeredFunctions,parameterManager);
  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.returningAttributeBindingMap=new LinkedHashMap<String,String>(0);
  }
 else {
    this.cteType=em.getMetamodel().entity(cteClass);
    this.cteName=cteType.getName();
    this.returningAttributeBindingMap=new LinkedHashMap<String,String>(cteType.getAttributes().size());
  }
}
Program: 168944
Project: 168944
Buggy source:
public BaseDeleteCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,alias,registeredFunctions,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(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions,ParameterManager parameterManager,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,alias,registeredFunctions,parameterManager,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");
  }
}
Program: 168945
Project: 168945
Buggy source:
public BaseInsertCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,null,registeredFunctions,cteClass,result,listener);
  if (!jpaProvider.supportsInsertStatement()) {
    throw new IllegalStateException("String_Node_Str");
  }
}

Fixed version (ground truth):
public BaseInsertCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,ParameterManager parameterManager,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,null,registeredFunctions,parameterManager,cteClass,result,listener);
  if (!jpaProvider.supportsInsertStatement()) {
    throw new IllegalStateException("String_Node_Str");
  }
}
Program: 168946
Project: 168946
Buggy source:
@Override protected void prepareAndCheck(){
  List<String> attributes=new ArrayList<String>(bindingMap.size());
  List<SelectInfo> originalSelectInfos=new ArrayList<SelectInfo>(selectManager.getSelectInfos());
  List<SelectInfo> newSelectInfos=selectManager.getSelectInfos();
  newSelectInfos.clear();
  for (  Map.Entry<String,Integer> attributeEntry : bindingMap.entrySet()) {
    Integer newPosition=attributes.size();
    attributes.add(attributeEntry.getKey());
    SelectInfo selectInfo=originalSelectInfos.get(attributeEntry.getValue());
    newSelectInfos.add(selectInfo);
    attributeEntry.setValue(newPosition);
  }
}

Fixed version (ground truth):
@Override protected void prepareAndCheck(){
  List<String> attributes=new ArrayList<String>(bindingMap.size());
  List<SelectInfo> originalSelectInfos=new ArrayList<SelectInfo>(selectManager.getSelectInfos());
  List<SelectInfo> newSelectInfos=selectManager.getSelectInfos();
  newSelectInfos.clear();
  for (  Map.Entry<String,Integer> attributeEntry : bindingMap.entrySet()) {
    Integer newPosition=attributes.size();
    attributes.add(attributeEntry.getKey());
    SelectInfo selectInfo=originalSelectInfos.get(attributeEntry.getValue());
    newSelectInfos.add(selectInfo);
    attributeEntry.setValue(newPosition);
  }
  super.prepareAndCheck();
}
Program: 168947
Project: 168947
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public X set(String attributeName,Object value){
  entityType.getAttribute(attributeName);
  setAttributes.add(attributeName);
  parameterManager.addParameterMapping(attributeName,value);
  return (X)this;
}

Fixed version (ground truth):
@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.getParamNameForObject(value);
  setAttributes.put(attributeName,paramName);
  return (X)this;
}
Program: 168948
Project: 168948
Buggy source:
@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 (  String attribute : setAttributes) {
    sbSelectFrom.append(attribute);
    sbSelectFrom.append("String_Node_Str");
    sbSelectFrom.append(attribute);
  }
  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: 168949
Project: 168949
Buggy source:
public BaseUpdateCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,alias,registeredFunctions,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(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions,ParameterManager parameterManager,Class<?> cteClass,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,alias,registeredFunctions,parameterManager,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");
  }
}
Program: 168950
Project: 168950
Buggy source:
public CTECriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,registeredFunctions,result,listener);
}

Fixed version (ground truth):
public CTECriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,ParameterManager parameterManager,Y result,CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,registeredFunctions,parameterManager,result,listener);
}
Program: 168951
Project: 168951
Buggy source:
<X,Y>SelectCTECriteriaBuilder<X,Y> with(Class<X> cteClass,Y result){
  CTECriteriaBuilderImpl<X,Y,T> cteBuilder=new CTECriteriaBuilderImpl<X,Y,T>(cbf,em,dbmsDialect,cteClass,registeredFunctions,result,this);
  this.onBuilderStarted(cteBuilder);
  return cteBuilder;
}

Fixed version (ground truth):
<X,Y>SelectCTECriteriaBuilder<X,Y> with(Class<X> cteClass,Y result){
  CTECriteriaBuilderImpl<X,Y,T> cteBuilder=new CTECriteriaBuilderImpl<X,Y,T>(cbf,em,dbmsDialect,cteClass,registeredFunctions,parameterManager,result,this);
  this.onBuilderStarted(cteBuilder);
  return cteBuilder;
}
Program: 168952
Project: 168952
Buggy source:
CTEManager(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Set<String> registeredFunctions){
  this.cbf=cbf;
  this.em=em;
  this.dbmsDialect=dbmsDialect;
  this.registeredFunctions=registeredFunctions;
  this.ctes=new LinkedHashSet<CTEInfo>();
}

Fixed version (ground truth):
CTEManager(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Set<String> registeredFunctions,ParameterManager parameterManager){
  this.cbf=cbf;
  this.em=em;
  this.dbmsDialect=dbmsDialect;
  this.registeredFunctions=registeredFunctions;
  this.parameterManager=parameterManager;
  this.ctes=new LinkedHashSet<CTEInfo>();
}
Program: 168953
Project: 168953
Buggy source:
<X,Y>SelectRecursiveCTECriteriaBuilder<X,Y> withRecursive(Class<X> cteClass,Y result){
  recursive=true;
  RecursiveCTECriteriaBuilderImpl<X,Y,T> cteBuilder=new RecursiveCTECriteriaBuilderImpl<X,Y,T>(cbf,em,dbmsDialect,cteClass,registeredFunctions,result,this);
  this.onBuilderStarted(cteBuilder);
  return cteBuilder;
}

Fixed version (ground truth):
<X,Y>SelectRecursiveCTECriteriaBuilder<X,Y> withRecursive(Class<X> cteClass,Y result){
  recursive=true;
  RecursiveCTECriteriaBuilderImpl<X,Y,T> cteBuilder=new RecursiveCTECriteriaBuilderImpl<X,Y,T>(cbf,em,dbmsDialect,cteClass,registeredFunctions,parameterManager,result,this);
  this.onBuilderStarted(cteBuilder);
  return cteBuilder;
}
Program: 168954
Project: 168954
Buggy source:
<X,Y>ReturningModificationCriteriaBuilderFactory<Y> withReturning(Class<X> cteClass,Y result){
  ReturningModificationCriteraBuilderFactoryImpl<Y> factory=new ReturningModificationCriteraBuilderFactoryImpl<Y>(cbf,em,dbmsDialect,registeredFunctions,cteClass,result,this);
  return factory;
}

Fixed version (ground truth):
<X,Y>ReturningModificationCriteriaBuilderFactory<Y> withReturning(Class<X> cteClass,Y result){
  ReturningModificationCriteraBuilderFactoryImpl<Y> factory=new ReturningModificationCriteraBuilderFactoryImpl<Y>(cbf,em,dbmsDialect,registeredFunctions,parameterManager,cteClass,result,this);
  return factory;
}
Program: 168955
Project: 168955
Buggy source:
public DeleteCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions){
  super(cbf,em,dbmsDialect,clazz,alias,registeredFunctions,null,null,null);
}

Fixed version (ground truth):
public DeleteCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,String alias,Set<String> registeredFunctions,ParameterManager parameterManager){
  super(cbf,em,dbmsDialect,clazz,alias,registeredFunctions,parameterManager,null,null,null);
}
Program: 168956
Project: 168956
Buggy source:
public InsertCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions){
  super(cbf,em,dbmsDialect,clazz,registeredFunctions,null,null,null);
}

Fixed version (ground truth):
public InsertCriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,ParameterManager parameterManager){
  super(cbf,em,dbmsDialect,clazz,registeredFunctions,parameterManager,null,null,null);
}
Program: 168957
Project: 168957
Buggy source:
@Override public SelectCTECriteriaBuilder<T,Y> unionAll(){
  verifyBuilderEnded();
  recursiveCteBuilder=new CTECriteriaBuilderImpl<T,Y,X>(cbf,em,dbmsDialect,clazz,registeredFunctions,result,this);
  return recursiveCteBuilder;
}

Fixed version (ground truth):
@Override public SelectCTECriteriaBuilder<T,Y> unionAll(){
  verifyBuilderEnded();
  recursiveCteBuilder=new CTECriteriaBuilderImpl<T,Y,X>(cbf,em,dbmsDialect,clazz,registeredFunctions,parameterManager,result,this);
  return recursiveCteBuilder;
}
Program: 168958
Project: 168958
Buggy source:
public RecursiveCTECriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,Y result,final CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,registeredFunctions,result,listener);
  this.clazz=clazz;
}

Fixed version (ground truth):
public RecursiveCTECriteriaBuilderImpl(CriteriaBuilderFactoryImpl cbf,EntityManager em,DbmsDialect dbmsDialect,Class<T> clazz,Set<String> registeredFunctions,ParameterManager parameterManager,Y result,final CTEBuilderListener listener){
  super(cbf,em,dbmsDialect,clazz,registeredFunctions,parameterManager,result,listener);
  this.clazz=clazz;
}
Program: 168959
Project: 168959
Buggy source:
public void appendLimit(StringBuilder sqlSb,String limit,String offset);

Fixed version (ground truth):
public void appendLimit(StringBuilder sqlSb,boolean isSubquery,String limit,String offset);
Program: 168960
Project: 168960
Buggy source:
protected void applyLimit(StringBuilder sqlSb){
  String limit=null;
  String offset=null;
  if (firstResult != 0) {
    offset=Integer.toString(firstResult);
  }
  if (maxResults != Integer.MAX_VALUE) {
    limit=Integer.toString(maxResults);
  }
  if (limit != null) {
    dbmsDialect.appendLimit(sqlSb,limit,offset);
  }
}

Fixed version (ground truth):
protected void applyLimit(StringBuilder sqlSb){
  String limit=null;
  String offset=null;
  if (firstResult != 0) {
    offset=Integer.toString(firstResult);
  }
  if (maxResults != Integer.MAX_VALUE) {
    limit=Integer.toString(maxResults);
  }
  if (limit != null) {
    dbmsDialect.appendLimit(sqlSb,false,limit,offset);
  }
}
Program: 168961
Project: 168961
Buggy source:
@Override public void appendLimit(StringBuilder sqlSb,String limit,String offset){
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str");
  }
 else {
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str").append(offset);
  }
}

Fixed version (ground truth):
@Override public void appendLimit(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str");
  }
 else {
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str").append(offset);
  }
}
Program: 168962
Project: 168962
Buggy source:
@Override public void appendLimit(StringBuilder sqlSb,String limit,String offset){
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit);
  }
 else {
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str").append(offset);
  }
}

Fixed version (ground truth):
@Override public void appendLimit(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit);
  }
 else {
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str").append(offset);
  }
}
Program: 168963
Project: 168963
Buggy source:
/** 
 * Uses a workaround for limit in IN predicates because of an limitation of MySQL. See http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html for reference.
 */
@Override public void appendLimit(StringBuilder sqlSb,String limit,String offset){
  String limitSubqueryAlias="String_Node_Str" + threadLocalCounter.get().incrementAndGet();
  sqlSb.insert(0,"String_Node_Str");
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str").append(limitSubqueryAlias);
  }
 else {
    sqlSb.append("String_Node_Str").append(offset).append(',').append(limit).append("String_Node_Str").append(limitSubqueryAlias);
  }
}

Fixed version (ground truth):
/** 
 * Uses a workaround for limit in IN predicates because of an limitation of MySQL. See http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html for reference.
 */
@Override public void appendLimit(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  if (isSubquery) {
    sqlSb.insert(0,"String_Node_Str");
  }
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit);
  }
 else {
    sqlSb.append("String_Node_Str").append(offset).append(',').append(limit);
  }
  if (isSubquery) {
    String limitSubqueryAlias="String_Node_Str" + threadLocalCounter.get().incrementAndGet();
    sqlSb.append("String_Node_Str").append(limitSubqueryAlias);
  }
}
Program: 168964
Project: 168964
Buggy source:
@Override public void appendLimit(StringBuilder sqlSb,String limit,String offset){
  if (offset == null) {
    sqlSb.insert(0,"String_Node_Str");
    sqlSb.append("String_Node_Str").append(limit);
  }
 else {
    sqlSb.insert(0,"String_Node_Str");
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str").append(offset);
  }
}

Fixed version (ground truth):
@Override public void appendLimit(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  if (offset == null) {
    sqlSb.insert(0,"String_Node_Str");
    sqlSb.append("String_Node_Str").append(limit);
  }
 else {
    sqlSb.insert(0,"String_Node_Str");
    sqlSb.append("String_Node_Str").append(limit).append("String_Node_Str").append(offset);
  }
}
Program: 168965
Project: 168965
Buggy source:
protected void renderLimitOffset(FunctionRenderContext functionRenderContext){
  StringBuilder sqlSb=getSql(functionRenderContext);
  dbmsDialect.appendLimit(sqlSb,functionRenderContext.getArgument(1),functionRenderContext.getArgument(2));
  sqlSb.insert(0,'(');
  sqlSb.append(')');
  functionRenderContext.addChunk(sqlSb.toString());
}

Fixed version (ground truth):
protected void renderLimitOffset(FunctionRenderContext functionRenderContext){
  StringBuilder sqlSb=getSql(functionRenderContext);
  dbmsDialect.appendLimit(sqlSb,true,functionRenderContext.getArgument(1),functionRenderContext.getArgument(2));
  sqlSb.insert(0,'(');
  sqlSb.append(')');
  functionRenderContext.addChunk(sqlSb.toString());
}
Program: 168966
Project: 168966
Buggy source:
protected void renderLimitOnly(FunctionRenderContext functionRenderContext){
  StringBuilder sqlSb=getSql(functionRenderContext);
  dbmsDialect.appendLimit(sqlSb,functionRenderContext.getArgument(1),null);
  sqlSb.insert(0,'(');
  sqlSb.append(')');
  functionRenderContext.addChunk(sqlSb.toString());
}

Fixed version (ground truth):
protected void renderLimitOnly(FunctionRenderContext functionRenderContext){
  StringBuilder sqlSb=getSql(functionRenderContext);
  dbmsDialect.appendLimit(sqlSb,true,functionRenderContext.getArgument(1),null);
  sqlSb.insert(0,'(');
  sqlSb.append(')');
  functionRenderContext.addChunk(sqlSb.toString());
}
Program: 168967
Project: 168967
Buggy source:
@Test @Category({NoH2.class,NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class}) public void testReturningLastWithCteAndLimit(){
  final InsertCriteriaBuilder<Document> cb=cbf.insert(em,Document.class);
  cb.with(PersonCTE.class).from(Person.class,"String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").end();
  cb.from(PersonCTE.class,"String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.orderByAsc("String_Node_Str");
  cb.setMaxResults(1);
  transactional(new TxVoidWork(){
    @Override public void work(){
      ReturningResult<Long> result=cb.executeWithReturning("String_Node_Str",Long.class);
      assertEquals(1,result.getUpdateCount());
      assertEquals(byOwner(p1).getId(),result.getLastResult());
    }
  }
);
}

Fixed version (ground truth):
@Test @Category({NoH2.class,NoMySQL.class,NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class}) public void testReturningLastWithCteAndLimit(){
  final InsertCriteriaBuilder<Document> cb=cbf.insert(em,Document.class);
  cb.with(PersonCTE.class).from(Person.class,"String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").end();
  cb.from(PersonCTE.class,"String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.orderByAsc("String_Node_Str");
  cb.setMaxResults(1);
  transactional(new TxVoidWork(){
    @Override public void work(){
      ReturningResult<Long> result=cb.executeWithReturning("String_Node_Str",Long.class);
      assertEquals(1,result.getUpdateCount());
      assertEquals(byOwner(p1).getId(),result.getLastResult());
    }
  }
);
}
Program: 168968
Project: 168968
Buggy source:
@Test @Category({NoH2.class,NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class}) public void testReturningLastWithCte(){
  final InsertCriteriaBuilder<Document> cb=cbf.insert(em,Document.class);
  cb.with(PersonCTE.class).from(Person.class,"String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").end();
  cb.from(PersonCTE.class,"String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.where("String_Node_Str").eq("String_Node_Str");
  cb.orderByAsc("String_Node_Str");
  transactional(new TxVoidWork(){
    @Override public void work(){
      ReturningResult<Long> result=cb.executeWithReturning("String_Node_Str",Long.class);
      assertEquals(1,result.getUpdateCount());
      assertEquals(byOwner(p2).getId(),result.getLastResult());
    }
  }
);
}

Fixed version (ground truth):
@Test @Category({NoH2.class,NoMySQL.class,NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class}) public void testReturningLastWithCte(){
  final InsertCriteriaBuilder<Document> cb=cbf.insert(em,Document.class);
  cb.with(PersonCTE.class).from(Person.class,"String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").bind("String_Node_Str").select("String_Node_Str").end();
  cb.from(PersonCTE.class,"String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.bind("String_Node_Str").select("String_Node_Str");
  cb.where("String_Node_Str").eq("String_Node_Str");
  cb.orderByAsc("String_Node_Str");
  transactional(new TxVoidWork(){
    @Override public void work(){
      ReturningResult<Long> result=cb.executeWithReturning("String_Node_Str",Long.class);
      assertEquals(1,result.getUpdateCount());
      assertEquals(byOwner(p2).getId(),result.getLastResult());
    }
  }
);
}
Program: 168969
Project: 168969
Buggy source:
/** 
 * TODO: documentation
 * @param cteClass
 * @return
 * @since 1.1.0
 */
public <X>SelectCTECriteriaBuilder<X,T> with(Class<X> cteClass);

Fixed version (ground truth):
/** 
 * TODO: documentation
 * @param cteClass
 * @return
 * @since 1.1.0
 */
public <X>FullSelectCTECriteriaBuilder<X,T> with(Class<X> cteClass);
Program: 168970
Project: 168970
Buggy source:
/** 
 * Finishes the CTE builder for the non-recursive part and starts the builder for the recursive part.
 * @return The parent query builder
 */
public SelectCTECriteriaBuilder<T,X> unionAll();

Fixed version (ground truth):
/** 
 * Finishes the CTE builder for the non-recursive part and starts the builder for the recursive part. The union all operator is used for connecting the non-recursive and recursive part, thus not removing duplicates.
 * @return The parent query builder
 */
public SelectCTECriteriaBuilder<T,X> unionAll();
Program: 168972
Project: 168972
Buggy source:
private boolean applyAddedCtes(Query query,AbstractCommonQueryBuilder<?,?> queryBuilder,StringBuilder sb,Map<String,String> tableNameRemapping,boolean firstCte){
  if (query instanceof CustomSQLQuery) {
    Map<String,String> cteTableNameRemappings=queryBuilder.getModificationStateRelatedTableNameRemappings(explicitVersionEntities);
    Map<String,String> addedCtes=((CustomSQLQuery)query).getAddedCtes();
    if (addedCtes != null && addedCtes.size() > 0) {
      for (      Map.Entry<String,String> simpleCteEntry : addedCtes.entrySet()) {
        for (        Map.Entry<String,String> cteTableNameRemapping : cteTableNameRemappings.entrySet()) {
          if (cteTableNameRemapping.getValue().equals(simpleCteEntry.getKey())) {
            tableNameRemapping.put(cteTableNameRemapping.getKey(),cteTableNameRemapping.getValue());
          }
        }
        if (firstCte) {
          firstCte=false;
        }
 else {
          sb.append("String_Node_Str");
        }
        sb.append(simpleCteEntry.getKey());
        sb.append("String_Node_Str");
        sb.append(simpleCteEntry.getValue());
        sb.append("String_Node_Str");
      }
    }
  }
  return firstCte;
}

Fixed version (ground truth):
private boolean applyAddedCtes(Query query,AbstractCommonQueryBuilder<?,?,?> queryBuilder,StringBuilder sb,Map<String,String> tableNameRemapping,boolean firstCte){
  if (query instanceof CustomSQLQuery) {
    Map<String,String> cteTableNameRemappings=queryBuilder.getModificationStateRelatedTableNameRemappings(explicitVersionEntities);
    Map<String,String> addedCtes=((CustomSQLQuery)query).getAddedCtes();
    if (addedCtes != null && addedCtes.size() > 0) {
      for (      Map.Entry<String,String> simpleCteEntry : addedCtes.entrySet()) {
        for (        Map.Entry<String,String> cteTableNameRemapping : cteTableNameRemappings.entrySet()) {
          if (cteTableNameRemapping.getValue().equals(simpleCteEntry.getKey())) {
            tableNameRemapping.put(cteTableNameRemapping.getKey(),cteTableNameRemapping.getValue());
          }
        }
        if (firstCte) {
          firstCte=false;
        }
 else {
          sb.append("String_Node_Str");
        }
        sb.append(simpleCteEntry.getKey());
        sb.append("String_Node_Str");
        sb.append(simpleCteEntry.getValue());
        sb.append("String_Node_Str");
      }
    }
  }
  return firstCte;
}
Program: 168973
Project: 168973
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);
      int currentSize=sb.length();
      sb.append(cteBaseName);
      sb.append('_').append(cteBaseNameCount);
      sb.append("String_Node_Str");
      cascadingDeleteSqlSb.setLength(0);
      cascadingDeleteSqlSb.append(cascadingDeleteSql);
      dbmsDialect.appendExtendedSql(cascadingDeleteSqlSb,DbmsStatementType.DELETE,true,null,null,null,null,null);
      sb.append(cascadingDeleteSqlSb);
      sb.append("String_Node_Str");
      for (      CTEInfo cteInfo : cteManager.getCtes()) {
        final String subselect="String_Node_Str" + cteInfo.name + "String_Node_Str";
        int subselectIndex=currentSize;
        while ((subselectIndex=sb.indexOf(subselect,subselectIndex)) > -1) {
          sb.replace(subselectIndex,subselectIndex + subselect.length(),cteInfo.name);
        }
      }
    }
  }
  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);
      int currentSize=sb.length();
      sb.append(cteBaseName);
      sb.append('_').append(cteBaseNameCount);
      sb.append("String_Node_Str");
      cascadingDeleteSqlSb.setLength(0);
      cascadingDeleteSqlSb.append(cascadingDeleteSql);
      dbmsDialect.appendExtendedSql(cascadingDeleteSqlSb,DbmsStatementType.DELETE,true,null,null,null,null,null);
      sb.append(cascadingDeleteSqlSb);
      sb.append("String_Node_Str");
      for (      CTEInfo cteInfo : cteManager.getCtes()) {
        final String subselect="String_Node_Str" + cteInfo.name + "String_Node_Str";
        int subselectIndex=currentSize;
        while ((subselectIndex=sb.indexOf(subselect,subselectIndex)) > -1) {
          sb.replace(subselectIndex,subselectIndex + subselect.length(),cteInfo.name);
        }
      }
    }
  }
  return firstCte;
}
Program: 168974
Project: 168974
Buggy source:
@SuppressWarnings("String_Node_Str") public <Y>SelectCTECriteriaBuilder<Y,X> with(Class<Y> cteClass){
  if (!dbmsDialect.supportsWithClause()) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return cteManager.with(cteClass,(X)this);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public <Y>FullSelectCTECriteriaBuilder<Y,X> with(Class<Y> cteClass){
  if (!dbmsDialect.supportsWithClause()) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return cteManager.with(cteClass,(X)this);
}
Program: 168975
Project: 168975
Buggy source:
public CTEInfo createCTEInfo(){
  List<String> attributes=prepareAndGetAttributes();
  CTEInfo info=new CTEInfo(cteName,cteType,attributes,false,this,null);
  return info;
}

Fixed version (ground truth):
public CTEInfo createCTEInfo(){
  List<String> attributes=prepareAndGetAttributes();
  CTEInfo info=new CTEInfo(cteName,cteType,attributes,false,false,this,null);
  return info;
}
Program: 168976
Project: 168976
Buggy source:
@Override public <Z>SelectCTECriteriaBuilder<Z,X> with(Class<Z> cteClass){
  if (!dbmsDialect.supportsWithClauseInModificationQuery()) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return super.with(cteClass);
}

Fixed version (ground truth):
@Override public <Z>FullSelectCTECriteriaBuilder<Z,X> with(Class<Z> cteClass){
  if (!dbmsDialect.supportsWithClauseInModificationQuery()) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  return super.with(cteClass);
}
Program: 168977
Project: 168977
Buggy source:
CTEInfo(String name,EntityType<?> cteType,List<String> attributes,boolean recursive,AbstractCommonQueryBuilder<?,?> nonRecursiveCriteriaBuilder,AbstractCommonQueryBuilder<?,?> recursiveCriteriaBuilder){
  this.name=name;
  this.cteType=cteType;
  this.attributes=attributes;
  this.recursive=recursive;
  this.nonRecursiveCriteriaBuilder=nonRecursiveCriteriaBuilder;
  this.recursiveCriteriaBuilder=recursiveCriteriaBuilder;
}

Fixed version (ground truth):
CTEInfo(String name,EntityType<?> cteType,List<String> attributes,boolean recursive,boolean unionAll,AbstractCommonQueryBuilder<?,?,?> nonRecursiveCriteriaBuilder,AbstractCommonQueryBuilder<?,?,?> recursiveCriteriaBuilder){
  this.name=name;
  this.cteType=cteType;
  this.attributes=attributes;
  this.recursive=recursive;
  this.unionAll=unionAll;
  this.nonRecursiveCriteriaBuilder=nonRecursiveCriteriaBuilder;
  this.recursiveCriteriaBuilder=recursiveCriteriaBuilder;
}
Program: 168978
Project: 168978
Buggy source:
<X,Y>SelectCTECriteriaBuilder<X,Y> with(Class<X> cteClass,Y result){
  CTECriteriaBuilderImpl<X,Y,T> cteBuilder=new CTECriteriaBuilderImpl<X,Y,T>(cbf,em,dbmsDialect,cteClass,registeredFunctions,parameterManager,result,this);
  this.onBuilderStarted(cteBuilder);
  return cteBuilder;
}

Fixed version (ground truth):
<X,Y>FullSelectCTECriteriaBuilder<X,Y> with(Class<X> cteClass,Y result){
  FullSelectCTECriteriaBuilderImpl<X,Y,T> cteBuilder=new FullSelectCTECriteriaBuilderImpl<X,Y,T>(cbf,em,dbmsDialect,cteClass,registeredFunctions,parameterManager,result,this);
  this.onBuilderStarted(cteBuilder);
  return cteBuilder;
}
Program: 168980
Project: 168980
Buggy source:
@Override public Map<String,String> appendExtendedSql(StringBuilder sqlSb,DbmsStatementType statementType,boolean isSubquery,StringBuilder withClause,String limit,String offset,String[] returningColumns,Map<DbmsModificationState,String> includedModificationStates){
  if (isSubquery && returningColumns != null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  sqlSb.insert(indexOfIgnoreCase(sqlSb,"String_Node_Str"),withClause);
  if (limit != null) {
    appendLimit(sqlSb,isSubquery,limit,offset);
  }
  return null;
}

Fixed version (ground truth):
@Override public Map<String,String> appendExtendedSql(StringBuilder sqlSb,DbmsStatementType statementType,boolean isSubquery,StringBuilder withClause,String limit,String offset,String[] returningColumns,Map<DbmsModificationState,String> includedModificationStates){
  if (isSubquery && returningColumns != null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (withClause != null) {
    sqlSb.insert(indexOfIgnoreCase(sqlSb,"String_Node_Str"),withClause);
  }
  if (limit != null) {
    appendLimit(sqlSb,isSubquery,limit,offset);
  }
  return null;
}
Program: 168981
Project: 168981
Buggy source:
protected void appendOrderBy(StringBuilder sqlSb,List<? extends OrderByElement> orderByElements){
  if (orderByElements.isEmpty()) {
    return;
  }
  sqlSb.append("String_Node_Str");
  boolean first=true;
  for (  OrderByElement element : orderByElements) {
    if (first) {
      first=false;
    }
 else {
      sqlSb.append(',');
    }
    sqlSb.append(element.getPosition());
    if (element.isAscending()) {
      sqlSb.append("String_Node_Str");
    }
 else {
      sqlSb.append("String_Node_Str");
    }
    if (element.isNullsFirst()) {
      sqlSb.append("String_Node_Str");
    }
 else {
      sqlSb.append("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
protected void appendOrderBy(StringBuilder sqlSb,List<? extends OrderByElement> orderByElements){
  if (orderByElements.isEmpty()) {
    return;
  }
  sqlSb.append("String_Node_Str");
  boolean first=true;
  for (  OrderByElement element : orderByElements) {
    if (first) {
      first=false;
    }
 else {
      sqlSb.append(',');
    }
    appendOrderByElement(sqlSb,element);
  }
}
Program: 168982
Project: 168982
Buggy source:
@Override public void appendSet(StringBuilder sqlSb,SetOperationType setType,boolean isSubquery,List<String> operands,List<? extends OrderByElement> orderByElements,String limit,String offset){
  if (isSubquery) {
    sqlSb.insert(0,'(');
  }
  if (operands.size() > 0) {
    String operator=getOperator(setType);
    boolean hasLimit=limit != null;
    boolean hasOrderBy=orderByElements.size() > 0;
    boolean first=true;
    for (    String operand : operands) {
      if (first) {
        first=false;
      }
 else {
        sqlSb.append("String_Node_Str");
        sqlSb.append(operator);
        sqlSb.append("String_Node_Str");
      }
      if ((hasLimit || hasOrderBy) && !operand.startsWith("String_Node_Str")) {
        sqlSb.append('(');
        sqlSb.append(operand);
        sqlSb.append(')');
      }
 else {
        sqlSb.append(operand);
      }
    }
    appendOrderBy(sqlSb,orderByElements);
    if (limit != null) {
      appendLimit(sqlSb,isSubquery,limit,offset);
    }
  }
  if (isSubquery) {
    sqlSb.append(')');
  }
}

Fixed version (ground truth):
@Override public void appendSet(StringBuilder sqlSb,SetOperationType setType,boolean isSubquery,List<String> operands,List<? extends OrderByElement> orderByElements,String limit,String offset){
  if (isSubquery) {
    sqlSb.insert(0,'(');
  }
  if (operands.size() > 0) {
    String operator=getOperator(setType);
    boolean hasLimit=limit != null;
    boolean hasOrderBy=orderByElements.size() > 0;
    boolean hasOuterClause=hasLimit || hasOrderBy;
    appendSetOperands(sqlSb,operator,isSubquery,operands,hasOuterClause);
    appendOrderBy(sqlSb,orderByElements);
    if (limit != null) {
      appendLimit(sqlSb,isSubquery,limit,offset);
    }
  }
  if (isSubquery) {
    sqlSb.append(')');
  }
}
Program: 168983
Project: 168983
Buggy source:
/** 
 * Uses a workaround for limit in IN predicates because of an limitation of MySQL. See http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html for reference.
 */
@Override public void appendLimit(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  if (isSubquery) {
    sqlSb.insert(0,"String_Node_Str");
  }
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit);
  }
 else {
    sqlSb.append("String_Node_Str").append(offset).append(',').append(limit);
  }
  if (isSubquery) {
    String limitSubqueryAlias="String_Node_Str" + threadLocalCounter.get().incrementAndGet();
    sqlSb.append("String_Node_Str").append(limitSubqueryAlias);
  }
}

Fixed version (ground truth):
/** 
 * Uses a workaround for limit in IN predicates because of an limitation of MySQL. See http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html for reference.
 */
@Override public void appendLimit(StringBuilder sqlSb,boolean isSubquery,String limit,String offset){
  if (isSubquery) {
    sqlSb.insert(1,"String_Node_Str");
  }
  if (offset == null) {
    sqlSb.append("String_Node_Str").append(limit);
  }
 else {
    sqlSb.append("String_Node_Str").append(offset).append(',').append(limit);
  }
  if (isSubquery) {
    String limitSubqueryAlias="String_Node_Str" + threadLocalCounter.get().incrementAndGet();
    sqlSb.append("String_Node_Str").append(limitSubqueryAlias);
  }
}
Program: 168984
Project: 168984
Buggy source:
@Test @Category({NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class,NoMySQL.class}) public void testAliasOrderByLimit(){
  FinalSetOperationCriteriaBuilder<String> cb=cbf.create(em,String.class).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);
  String expected="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" + renderNullPrecedence("String_Node_Str","String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ renderNullPrecedence("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({NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class,NoMySQL.class}) public void testAliasOrderByLimit(){
  FinalSetOperationCriteriaBuilder<String> cb=cbf.create(em,String.class).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);
  String expected="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: 168985
Project: 168985
Buggy source:
@Test @Category({NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class,NoMySQL.class}) public void testAttributeOrderByLimit(){
  FinalSetOperationCriteriaBuilder<Document> cb=cbf.create(em,Document.class).from(Document.class,"String_Node_Str").select("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").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);
  String expected="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" + renderNullPrecedence("String_Node_Str","String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ renderNullPrecedence("String_Node_Str","String_Node_Str","String_Node_Str")+ "String_Node_Str";
  assertEquals(expected,cb.getQueryString());
  List<Document> resultList=cb.getResultList();
  assertEquals(1,resultList.size());
  assertEquals("String_Node_Str",resultList.get(0).getName());
}

Fixed version (ground truth):
@Test @Category({NoDatanucleus.class,NoEclipselink.class,NoOpenJPA.class,NoMySQL.class}) public void testAttributeOrderByLimit(){
  FinalSetOperationCriteriaBuilder<Document> cb=cbf.create(em,Document.class).from(Document.class,"String_Node_Str").select("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").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);
  String expected="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<Document> resultList=cb.getResultList();
  assertEquals(1,resultList.size());
  assertEquals("String_Node_Str",resultList.get(0).getName());
}