nus-yam/ex-repair huggingface dataset:
Program: 168784
Project: 168784
Buggy source:
private void updateClauseDependencies(JoinNode baseNode,ClauseType clauseDependency,Set<JoinNode> seenNodes){
  if (!seenNodes.add(baseNode)) {
    throw new IllegalStateException("String_Node_Str" + seenNodes);
  }
  JoinNode current=baseNode;
  while (current != null) {
    for (    JoinNode dependency : current.getDependencies()) {
      updateClauseDependencies(dependency,clauseDependency,seenNodes);
    }
    current.getClauseDependencies().add(clauseDependency);
    current=current.getParent();
  }
}

Fixed version (ground truth):
private void updateClauseDependencies(JoinNode baseNode,ClauseType clauseDependency,Set<JoinNode> seenNodes){
  if (!seenNodes.add(baseNode)) {
    throw new IllegalStateException("String_Node_Str" + seenNodes);
  }
  JoinNode current=baseNode;
  while (current != null) {
    for (    JoinNode dependency : current.getDependencies()) {
      updateClauseDependencies(dependency,clauseDependency,seenNodes);
    }
    current.getClauseDependencies().add(clauseDependency);
    if (current.getDependencies().contains(current.getParent())) {
      break;
    }
    current=current.getParent();
  }
}
Program: 168787
Project: 168787
Buggy source:
/** 
 * Collects all mappings that involve the use of a collection attribute for duplicate usage checks.
 * @param managedType The JPA type against which to evaluate the mapping
 * @param context The metamodel context
 * @return The mappings which contain collection attribute uses
 */
public Set<String> getCollectionJoinMappings(ManagedType<?> managedType,MetamodelBuildingContext context){
  if (mapping == null || isQueryParameter()) {
    return Collections.emptySet();
  }
  CollectionJoinMappingGathererExpressionVisitor visitor=new CollectionJoinMappingGathererExpressionVisitor(managedType,context.getEntityMetamodel());
  String expression=stripThisFromMapping(mapping);
  if (expression.isEmpty()) {
    return Collections.emptySet();
  }
  context.getExpressionFactory().createSimpleExpression(expression,false).accept(visitor);
  Set<String> mappings=new HashSet<String>();
  for (  String s : visitor.getPaths()) {
    mappings.add(s);
  }
  return mappings;
}

Fixed version (ground truth):
/** 
 * Collects all mappings that involve the use of a collection attribute for duplicate usage checks.
 * @param managedType The JPA type against which to evaluate the mapping
 * @param context The metamodel context
 * @return The mappings which contain collection attribute uses
 */
public Set<String> getCollectionJoinMappings(ManagedType<?> managedType,MetamodelBuildingContext context){
  if (mapping == null || isQueryParameter() || getAttributeType() == AttributeType.SINGULAR) {
    return Collections.emptySet();
  }
  CollectionJoinMappingGathererExpressionVisitor visitor=new CollectionJoinMappingGathererExpressionVisitor(managedType,context.getEntityMetamodel());
  String expression=stripThisFromMapping(mapping);
  if (expression.isEmpty()) {
    return Collections.emptySet();
  }
  context.getExpressionFactory().createSimpleExpression(expression,false).accept(visitor);
  Set<String> mappings=new HashSet<String>();
  for (  String s : visitor.getPaths()) {
    mappings.add(s);
  }
  return mappings;
}
Program: 168788
Project: 168788
Buggy source:
public static Annotation getMapping(Constructor<?> constructor,int index,MetamodelBuildingContext context){
  Annotation[] annotations=constructor.getParameterAnnotations()[index];
  for (  Annotation a : annotations) {
    if (MappingParameter.class.isInstance(a) || Mapping.class.isInstance(a) || MappingSubquery.class.isInstance(a)|| MappingCorrelated.class.isInstance(a)) {
      return a;
    }
  }
  context.addError("String_Node_Str" + ParameterAttributeMapping.getLocation(constructor,index));
  return null;
}

Fixed version (ground truth):
public static Annotation getMapping(Constructor<?> constructor,int index,MetamodelBuildingContext context){
  Annotation[] annotations=constructor.getParameterAnnotations()[index];
  for (  Annotation a : annotations) {
    if (MappingParameter.class.isInstance(a) || Mapping.class.isInstance(a) || MappingSubquery.class.isInstance(a)|| MappingCorrelated.class.isInstance(a)|| MappingCorrelatedSimple.class.isInstance(a)) {
      return a;
    }
  }
  context.addError("String_Node_Str" + ParameterAttributeMapping.getLocation(constructor,index));
  return null;
}
Program: 168789
Project: 168789
Buggy source:
public Class<?> getJavaType(){
  return getType().getJavaType();
}

Fixed version (ground truth):
public Class<?> getJavaType(){
  Type<?> t=getType();
  if (t == null) {
    return null;
  }
  return t.getJavaType();
}
Program: 168790
Project: 168790
Buggy source:
@Override protected Class<?> resolveKeyType(){
  Class<?> attributeType=ReflectionUtils.getResolvedMethodReturnType(entityViewClass,method);
  Class<?>[] typeArguments=ReflectionUtils.getResolvedMethodReturnTypeArguments(entityViewClass,method);
  if (typeArguments.length == 0 || AnnotationUtils.findAnnotation(method,MappingSingular.class) != null || !Map.class.isAssignableFrom(attributeType)) {
    return null;
  }
  return typeArguments[0];
}

Fixed version (ground truth):
@Override protected Class<?> resolveKeyType(){
  Class<?> attributeType=ReflectionUtils.getResolvedMethodReturnType(entityViewClass,method);
  Class<?>[] typeArguments=ReflectionUtils.getResolvedMethodReturnTypeArguments(entityViewClass,method);
  if (typeArguments.length == 0 || AnnotationUtils.findAnnotation(method,MappingSingular.class) != null || AnnotationUtils.findAnnotation(method,MappingParameter.class) != null || !Map.class.isAssignableFrom(attributeType)) {
    return null;
  }
  return typeArguments[0];
}
Program: 168791
Project: 168791
Buggy source:
@Override protected Class<?> resolveElementType(){
  Class<?> attributeType=ReflectionUtils.getResolvedMethodReturnType(entityViewClass,method);
  Class<?>[] typeArguments=ReflectionUtils.getResolvedMethodReturnTypeArguments(entityViewClass,method);
  if (typeArguments.length == 0 || AnnotationUtils.findAnnotation(method,MappingSingular.class) != null) {
    return attributeType;
  }
  return typeArguments[typeArguments.length - 1];
}

Fixed version (ground truth):
@Override protected Class<?> resolveElementType(){
  Class<?> attributeType=ReflectionUtils.getResolvedMethodReturnType(entityViewClass,method);
  Class<?>[] typeArguments=ReflectionUtils.getResolvedMethodReturnTypeArguments(entityViewClass,method);
  if (typeArguments.length == 0 || AnnotationUtils.findAnnotation(method,MappingSingular.class) != null || AnnotationUtils.findAnnotation(method,MappingParameter.class) != null) {
    return attributeType;
  }
  return typeArguments[typeArguments.length - 1];
}
Program: 168792
Project: 168792
Buggy source:
@Override protected Class<?> resolveKeyType(){
  Class<?> concreteClass=constructor.getDeclaringClass();
  Type parameterType=constructor.getGenericParameterTypes()[index];
  Class<?>[] typeArguments=ReflectionUtils.resolveTypeArguments(concreteClass,parameterType);
  if (typeArguments.length == 0 || findAnnotation(MappingSingular.class) != null || !Map.class.isAssignableFrom(resolveType())) {
    return null;
  }
  return typeArguments[0];
}

Fixed version (ground truth):
@Override protected Class<?> resolveKeyType(){
  Class<?> concreteClass=constructor.getDeclaringClass();
  Type parameterType=constructor.getGenericParameterTypes()[index];
  Class<?>[] typeArguments=ReflectionUtils.resolveTypeArguments(concreteClass,parameterType);
  if (typeArguments.length == 0 || findAnnotation(MappingSingular.class) != null || findAnnotation(MappingParameter.class) != null || !Map.class.isAssignableFrom(resolveType())) {
    return null;
  }
  return typeArguments[0];
}
Program: 168793
Project: 168793
Buggy source:
@Override protected Class<?> resolveElementType(){
  Class<?> concreteClass=constructor.getDeclaringClass();
  Type parameterType=constructor.getGenericParameterTypes()[index];
  Class<?>[] typeArguments=ReflectionUtils.resolveTypeArguments(concreteClass,parameterType);
  if (typeArguments.length == 0 || findAnnotation(MappingSingular.class) != null) {
    return resolveType();
  }
  return typeArguments[typeArguments.length - 1];
}

Fixed version (ground truth):
@Override protected Class<?> resolveElementType(){
  Class<?> concreteClass=constructor.getDeclaringClass();
  Type parameterType=constructor.getGenericParameterTypes()[index];
  Class<?>[] typeArguments=ReflectionUtils.resolveTypeArguments(concreteClass,parameterType);
  if (typeArguments.length == 0 || findAnnotation(MappingSingular.class) != null || findAnnotation(MappingParameter.class) != null) {
    return resolveType();
  }
  return typeArguments[typeArguments.length - 1];
}
Program: 168794
Project: 168794
Buggy source:
private void applyJoins(StringBuilder sb,JoinAliasInfo joinBase,List<JoinNode> stack,boolean isCollection,Set<ClauseType> clauseExclusions,String aliasPrefix,boolean collectCollectionJoinNodes,boolean renderFetches,Set<JoinNode> nodesToFetch){
  while (!stack.isEmpty()) {
    JoinNode node=stack.remove(stack.size() - 1);
    if (!clauseExclusions.isEmpty() && clauseExclusions.containsAll(node.getClauseDependencies()) && !node.isCardinalityMandatory()) {
      continue;
    }
    stack.addAll(node.getEntityJoinNodes());
    stack.addAll(node.getTreatedJoinNodes().values());
    if (!node.getDependencies().isEmpty()) {
      renderReverseDependency(sb,node,aliasPrefix,renderFetches,nodesToFetch);
    }
    if (collectCollectionJoinNodes && isCollection) {
      collectionJoinNodes.add(node);
    }
    renderJoinNode(sb,joinBase,node,aliasPrefix,renderFetches,nodesToFetch);
    if (!node.getNodes().isEmpty()) {
      applyJoins(sb,node.getAliasInfo(),node.getNodes(),clauseExclusions,aliasPrefix,collectCollectionJoinNodes,renderFetches,nodesToFetch);
    }
  }
}

Fixed version (ground truth):
private void applyJoins(StringBuilder sb,JoinAliasInfo joinBase,List<JoinNode> stack,boolean isCollection,Set<ClauseType> clauseExclusions,String aliasPrefix,boolean collectCollectionJoinNodes,boolean renderFetches,Set<JoinNode> nodesToFetch,List<String> whereConjuncts){
  while (!stack.isEmpty()) {
    JoinNode node=stack.remove(stack.size() - 1);
    if (!clauseExclusions.isEmpty() && clauseExclusions.containsAll(node.getClauseDependencies()) && !node.isCardinalityMandatory()) {
      continue;
    }
    stack.addAll(node.getEntityJoinNodes());
    stack.addAll(node.getTreatedJoinNodes().values());
    if (!node.getDependencies().isEmpty()) {
      renderReverseDependency(sb,node,aliasPrefix,renderFetches,nodesToFetch,whereConjuncts);
    }
    if (collectCollectionJoinNodes && isCollection) {
      collectionJoinNodes.add(node);
    }
    renderJoinNode(sb,joinBase,node,aliasPrefix,renderFetches,nodesToFetch,whereConjuncts);
    if (!node.getNodes().isEmpty()) {
      applyJoins(sb,node.getAliasInfo(),node.getNodes(),clauseExclusions,aliasPrefix,collectCollectionJoinNodes,renderFetches,nodesToFetch,whereConjuncts);
    }
  }
}
Program: 168795
Project: 168795
Buggy source:
private void renderCorrelationJoinPath(StringBuilder sb,JoinAliasInfo joinBase,JoinNode node){
  if (node.getTreatType() != null) {
    if (mainQuery.jpaProvider.supportsTreatCorrelation()) {
      sb.append("String_Node_Str");
      renderAlias(sb,joinBase.getJoinNode(),mainQuery.jpaProvider.supportsRootTreat());
      sb.append('.');
      sb.append(node.getCorrelationPath());
      sb.append("String_Node_Str");
      sb.append(node.getTreatType().getName());
      sb.append(')');
    }
 else     if (mainQuery.jpaProvider.supportsSubtypeRelationResolving()) {
      sb.append(joinBase.getAlias()).append('.').append(node.getCorrelationPath());
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 else {
    JoinNode baseNode=joinBase.getJoinNode();
    if (baseNode.getTreatType() != null) {
      if (mainQuery.jpaProvider.supportsRootTreatJoin()) {
        baseNode.appendAlias(sb,true);
      }
 else       if (mainQuery.jpaProvider.supportsSubtypeRelationResolving()) {
        baseNode.appendAlias(sb,false);
      }
 else {
        throw new IllegalArgumentException("String_Node_Str");
      }
    }
 else {
      baseNode.appendAlias(sb,false);
    }
    sb.append('.').append(node.getCorrelationPath());
  }
}

Fixed version (ground truth):
private void renderCorrelationJoinPath(StringBuilder sb,JoinAliasInfo joinBase,JoinNode node){
  if (node.getTreatType() != null) {
    final boolean renderTreat=mainQuery.jpaProvider.supportsTreatJoin() && (!mainQuery.jpaProvider.supportsSubtypeRelationResolving() || node.getJoinType() == JoinType.INNER);
    if (renderTreat) {
      sb.append("String_Node_Str");
      renderAlias(sb,joinBase.getJoinNode(),mainQuery.jpaProvider.supportsRootTreat());
      sb.append('.');
      sb.append(node.getCorrelationPath());
      sb.append("String_Node_Str");
      sb.append(node.getTreatType().getName());
      sb.append(')');
    }
 else     if (mainQuery.jpaProvider.supportsSubtypeRelationResolving()) {
      sb.append(joinBase.getAlias()).append('.').append(node.getCorrelationPath());
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
 else {
    JoinNode baseNode=joinBase.getJoinNode();
    if (baseNode.getTreatType() != null) {
      if (mainQuery.jpaProvider.supportsRootTreatJoin()) {
        baseNode.appendAlias(sb,true);
      }
 else       if (mainQuery.jpaProvider.supportsSubtypeRelationResolving()) {
        baseNode.appendAlias(sb,false);
      }
 else {
        throw new IllegalArgumentException("String_Node_Str");
      }
    }
 else {
      baseNode.appendAlias(sb,false);
    }
    sb.append('.').append(node.getCorrelationPath());
  }
}
Program: 168797
Project: 168797
Buggy source:
private void renderReverseDependency(StringBuilder sb,JoinNode dependency,String aliasPrefix,boolean renderFetches,Set<JoinNode> nodesToFetch){
  if (dependency.getParent() != null) {
    renderReverseDependency(sb,dependency.getParent(),aliasPrefix,renderFetches,nodesToFetch);
    if (!dependency.getDependencies().isEmpty()) {
      markedJoinNodes.add(dependency);
      try {
        for (        JoinNode dep : dependency.getDependencies()) {
          if (markedJoinNodes.contains(dep)) {
            throw new IllegalStateException("String_Node_Str" + dep.getAliasInfo().getAbsolutePath() + "String_Node_Str"+ dep.getAliasInfo().getAlias()+ "String_Node_Str");
          }
          renderReverseDependency(sb,dep,aliasPrefix,renderFetches,nodesToFetch);
        }
      }
  finally {
        markedJoinNodes.remove(dependency);
      }
    }
    renderJoinNode(sb,dependency.getParent().getAliasInfo(),dependency,aliasPrefix,renderFetches,nodesToFetch);
  }
}

Fixed version (ground truth):
private void renderReverseDependency(StringBuilder sb,JoinNode dependency,String aliasPrefix,boolean renderFetches,Set<JoinNode> nodesToFetch,List<String> whereConjuncts){
  if (dependency.getParent() != null) {
    renderReverseDependency(sb,dependency.getParent(),aliasPrefix,renderFetches,nodesToFetch,whereConjuncts);
    if (!dependency.getDependencies().isEmpty()) {
      markedJoinNodes.add(dependency);
      try {
        for (        JoinNode dep : dependency.getDependencies()) {
          if (markedJoinNodes.contains(dep)) {
            throw new IllegalStateException("String_Node_Str" + dep.getAliasInfo().getAbsolutePath() + "String_Node_Str"+ dep.getAliasInfo().getAlias()+ "String_Node_Str");
          }
          renderReverseDependency(sb,dep,aliasPrefix,renderFetches,nodesToFetch,whereConjuncts);
        }
      }
  finally {
        markedJoinNodes.remove(dependency);
      }
    }
    renderJoinNode(sb,dependency.getParent().getAliasInfo(),dependency,aliasPrefix,renderFetches,nodesToFetch,whereConjuncts);
  }
}
Program: 168800
Project: 168800
Buggy source:
/** 
 * Creates a new   {@link JpaCountQueryCreator}.
 * @param tree
 * @param domainClass
 * @param parameters
 * @param em
 */
public FixedJpaCountQueryCreator(PartTree tree,Class<?> domainClass,CriteriaBuilder builder,ParameterMetadataProvider provider){
  super(tree,domainClass,builder,provider);
}

Fixed version (ground truth):
public FixedJpaCountQueryCreator(PartTree tree,Class<?> domainClass,CriteriaBuilder builder,ParameterMetadataProvider provider){
  super(tree,domainClass,builder,provider);
}
Program: 168801
Project: 168801
Buggy source:
/** 
 * Creates a   {@link Predicate} from the given {@link Part}.
 * @param part
 * @param root
 * @param iterator
 * @return
 */
private Predicate toPredicate(Part part,Root<?> root){
  return new FixedJpaQueryCreator.PredicateBuilder(part,root).build();
}

Fixed version (ground truth):
/** 
 * Creates a   {@link Predicate} from the given {@link Part}.
 * @param part
 * @param root
 * @return
 */
private Predicate toPredicate(Part part,Root<?> root){
  return new FixedJpaQueryCreator.PredicateBuilder(part,root).build();
}
Program: 168802
Project: 168802
Buggy source:
@Override protected void buildExternalQueryString(StringBuilder sbSelectFrom){
  buildBaseQueryString(sbSelectFrom,true);
  applyJpaLimit(sbSelectFrom);
}

Fixed version (ground truth):
@Override protected void buildExternalQueryString(StringBuilder sbSelectFrom){
  buildBaseQueryString(sbSelectFrom,true);
}
Program: 168803
Project: 168803
Buggy source:
protected void buildBaseQueryString(StringBuilder sbSelectFrom,boolean externalRepresentation){
  appendSelectClause(sbSelectFrom);
  List<String> whereClauseConjuncts=appendFromClause(sbSelectFrom,externalRepresentation);
  appendWhereClause(sbSelectFrom,whereClauseConjuncts);
  appendGroupByClause(sbSelectFrom);
  appendOrderByClause(sbSelectFrom);
}

Fixed version (ground truth):
protected void buildBaseQueryString(StringBuilder sbSelectFrom,boolean externalRepresentation){
  appendSelectClause(sbSelectFrom);
  List<String> whereClauseConjuncts=appendFromClause(sbSelectFrom,externalRepresentation);
  appendWhereClause(sbSelectFrom,whereClauseConjuncts);
  appendGroupByClause(sbSelectFrom);
  appendOrderByClause(sbSelectFrom);
  if (externalRepresentation) {
    if (!(this instanceof SubqueryInternalBuilder<?>)) {
      applyJpaLimit(sbSelectFrom);
    }
  }
}
Program: 168806
Project: 168806
Buggy source:
protected Map<String,String> applyExtendedSql(StringBuilder sqlSb,boolean isSubquery,boolean isEmbedded,StringBuilder withClause,String[] returningColumns,Map<DbmsModificationState,String> includedModificationStates){
  return dbmsDialect.appendExtendedSql(sqlSb,statementType,isSubquery,isEmbedded,withClause,null,null,returningColumns,includedModificationStates);
}

Fixed version (ground truth):
protected Map<String,String> applyExtendedSql(StringBuilder sqlSb,boolean isSubquery,boolean isEmbedded,StringBuilder withClause,String[] returningColumns,Map<DbmsModificationState,String> includedModificationStates){
  return dbmsDialect.appendExtendedSql(sqlSb,statementType,isSubquery,isEmbedded,withClause,limit,offset,returningColumns,includedModificationStates);
}
Program: 168809
Project: 168809
Buggy source:
public void removeOperand(AbstractCommonQueryBuilder<?,?,?,?,?> operand){
  if (startQueryBuilder == operand) {
    return;
  }
 else {
    for (int i=0; i < setOperations.size(); i++) {
      if (setOperations.get(i) == operand) {
        setOperations.remove(i);
        return;
      }
    }
  }
}

Fixed version (ground truth):
public boolean removeOperand(AbstractCommonQueryBuilder<?,?,?,?,?> operand){
  BaseFinalSetOperationBuilderImpl<?,?,?> finalSetOperationBuilder;
  if (startQueryBuilder == operand) {
    startQueryBuilder=null;
    return true;
  }
  if (startQueryBuilder instanceof BaseFinalSetOperationBuilderImpl && ((BaseFinalSetOperationBuilderImpl)startQueryBuilder).setOperationManager.removeOperand(operand)) {
    return true;
  }
  for (int i=0; i < setOperations.size(); i++) {
    if (setOperations.get(i) == operand) {
      setOperations.remove(i);
      return true;
    }
    if (setOperations.get(i) instanceof BaseFinalSetOperationBuilderImpl && (finalSetOperationBuilder=(BaseFinalSetOperationBuilderImpl)setOperations.get(i)).setOperationManager.removeOperand(operand)) {
      if (finalSetOperationBuilder.isEmpty()) {
        setOperations.remove(i);
      }
      return true;
    }
  }
  return false;
}
Program: 168811
Project: 168811
Buggy source:
public ReducerViewTypeObjectBuilder(ObjectBuilder<T> delegate,int start,int length){
  super(delegate);
  this.start=start;
  this.length=length;
  this.newTuple=new FastArrayList(length);
}

Fixed version (ground truth):
public ReducerViewTypeObjectBuilder(ObjectBuilder<T> delegate,int start,int length,boolean keepTuplePrefix){
  super(delegate);
  this.start=start;
  this.length=length;
  this.keepTuplePrefix=keepTuplePrefix;
  this.newTuple=new FastArrayList(length);
}
Program: 168812
Project: 168812
Buggy source:
@Override public T build(Object[] tuple){
  newTuple.clear();
  for (int i=start; i < start + length; i++) {
    if (tuple[i] != TupleReuse.CONSUMED) {
      newTuple.add(tuple[i]);
    }
  }
  return super.build(newTuple.getArray());
}

Fixed version (ground truth):
@Override public T build(Object[] tuple){
  newTuple.clear();
  for (int i=start; i < start + length; i++) {
    if (tuple[i] != TupleReuse.CONSUMED) {
      newTuple.add(tuple[i]);
    }
  }
  T result=super.build(newTuple.getArray());
  if (keepTuplePrefix) {
    Object[] tupleWithPrefix=new Object[start + 1];
    System.arraycopy(tuple,0,tupleWithPrefix,0,start);
    tupleWithPrefix[start]=result;
    result=(T)tupleWithPrefix;
  }
  return result;
}
Program: 168813
Project: 168813
Buggy source:
public ViewTypeObjectBuilderTemplate<?> createValue(EntityViewManagerImpl evm,ProxyFactory proxyFactory){
  int[] idPositions=new int[]{0};
  List<String> mappingPrefixes=null;
  if (entityViewRoot != null && entityViewRoot.length() > 0) {
    mappingPrefixes=Arrays.asList(entityViewRoot);
  }
  return new ViewTypeObjectBuilderTemplate<Object>(viewType,entityViewRoot,"String_Node_Str",name,mappingPrefixes,entityViewRoot,idPositions,offset,evm,ef,viewType,constructor,proxyFactory);
}

Fixed version (ground truth):
public ViewTypeObjectBuilderTemplate<?> createValue(EntityViewManagerImpl evm,ProxyFactory proxyFactory){
  int[] idPositions=new int[offset + 1];
  for (int i=0; i <= offset; i++) {
    idPositions[i]=i;
  }
  List<String> mappingPrefixes=null;
  if (entityViewRoot != null && entityViewRoot.length() > 0) {
    mappingPrefixes=Arrays.asList(entityViewRoot);
  }
  return new ViewTypeObjectBuilderTemplate<Object>(viewType,entityViewRoot,"String_Node_Str",name,mappingPrefixes,entityViewRoot,idPositions,offset,evm,ef,viewType,constructor,proxyFactory);
}
Program: 168814
Project: 168814
Buggy source:
public ObjectBuilder<T> createObjectBuilder(FullQueryBuilder<?,?> queryBuilder,Map<String,Object> optionalParameters,EntityViewConfiguration entityViewConfiguration,boolean isSubview){
  boolean hasOffset=tupleOffset != 0;
  ObjectBuilder<T> result;
  result=new ViewTypeObjectBuilder<T>(this,queryBuilder,optionalParameters);
  if (hasOffset || isSubview || hasIndexedCollections|| hasSubviews) {
    result=new ReducerViewTypeObjectBuilder<T>(result,tupleOffset,mappers.length);
  }
  if (hasParameters) {
    result=new ParameterViewTypeObjectBuilder<T>(result,this,queryBuilder,optionalParameters,tupleOffset);
  }
  if (tupleTransformatorFactory.hasTransformers() && !isSubview) {
    result=new ChainingObjectBuilder<T>(tupleTransformatorFactory,result,queryBuilder,optionalParameters,entityViewConfiguration,tupleOffset);
  }
  return result;
}

Fixed version (ground truth):
public ObjectBuilder<T> createObjectBuilder(FullQueryBuilder<?,?> queryBuilder,Map<String,Object> optionalParameters,EntityViewConfiguration entityViewConfiguration,boolean isSubview){
  boolean hasOffset=tupleOffset != 0;
  ObjectBuilder<T> result;
  result=new ViewTypeObjectBuilder<T>(this,queryBuilder,optionalParameters);
  if (hasOffset || isSubview || hasIndexedCollections|| hasSubviews) {
    result=new ReducerViewTypeObjectBuilder<T>(result,tupleOffset,mappers.length,!isSubview && tupleOffset > 0);
  }
  if (hasParameters) {
    result=new ParameterViewTypeObjectBuilder<T>(result,this,queryBuilder,optionalParameters,tupleOffset);
  }
  if (tupleTransformatorFactory.hasTransformers() && !isSubview) {
    result=new ChainingObjectBuilder<T>(tupleTransformatorFactory,result,queryBuilder,optionalParameters,entityViewConfiguration,tupleOffset);
  }
  return result;
}
Program: 168815
Project: 168815
Buggy source:
@Override @SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void finish(FullQueryBuilder<?,?> criteriaBuilder,EntityViewConfiguration entityViewConfiguration,int tupleOffset,String correlationRoot){
  ObjectBuilder builder=evm.createObjectBuilder((ViewType<?>)managedViewType,null,viewName,correlationRoot,criteriaBuilder,entityViewConfiguration,tupleOffset,false);
  if (tupleOffset == 0) {
    criteriaBuilder.selectNew(builder);
  }
 else {
    criteriaBuilder.selectNew(new PrefixedObjectBuilder(builder,tupleOffset));
  }
}

Fixed version (ground truth):
@Override @SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void finish(FullQueryBuilder<?,?> criteriaBuilder,EntityViewConfiguration entityViewConfiguration,int tupleOffset,String correlationRoot){
  ObjectBuilder builder=evm.createObjectBuilder((ViewType<?>)managedViewType,null,viewName,correlationRoot,criteriaBuilder,entityViewConfiguration,tupleOffset,false);
  criteriaBuilder.selectNew(builder);
}
Program: 168819
Project: 168819
Buggy source:
public DelegatingKeysetExtractionObjectBuilder(ObjectBuilder<T> objectBuilder,int keysetSize){
  super(keysetSize);
  this.objectBuilder=objectBuilder;
}

Fixed version (ground truth):
public DelegatingKeysetExtractionObjectBuilder(ObjectBuilder<T> objectBuilder,int keysetSize,KeysetMode keysetMode){
  super(keysetSize,keysetMode);
  this.objectBuilder=objectBuilder;
}
Program: 168820
Project: 168820
Buggy source:
public KeysetExtractionObjectBuilder(int keysetSize){
  this.keysetSize=keysetSize;
}

Fixed version (ground truth):
public KeysetExtractionObjectBuilder(int keysetSize,KeysetMode keysetMode){
  this.keysetSize=keysetSize;
  this.keysetMode=keysetMode;
}
Program: 168821
Project: 168821
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public T build(Object[] tuple){
  Object[] newTuple=new Object[tuple.length - keysetSize];
  System.arraycopy(tuple,0,newTuple,0,newTuple.length);
  if (first == null) {
    first=tuple;
    last=tuple;
  }
 else {
    last=tuple;
  }
  return (T)newTuple;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public T build(Object[] tuple){
  Object[] newTuple=new Object[tuple.length - keysetSize];
  System.arraycopy(tuple,0,newTuple,0,newTuple.length);
  if (keysetMode == KeysetMode.PREVIOUS) {
    if (first == null) {
      first=tuple;
      last=tuple;
    }
 else {
      first=tuple;
    }
  }
 else {
    if (first == null) {
      first=tuple;
      last=tuple;
    }
 else {
      last=tuple;
    }
  }
  return (T)newTuple;
}
Program: 168822
Project: 168822
Buggy source:
private boolean needsValueFunction(PathExpression expression){
  JoinNode baseNode=(JoinNode)expression.getBaseNode();
  return !expression.isCollectionKeyPath() && baseNode.getParentTreeNode() != null && baseNode.getParentTreeNode().isMap() && expression.getField() == null;
}

Fixed version (ground truth):
private boolean needsValueFunction(PathExpression expression){
  JoinNode baseNode=(JoinNode)expression.getBaseNode();
  return !expression.isCollectionKeyPath() && baseNode.getParentTreeNode() != null && baseNode.getParentTreeNode().isMap() && (expression.getField() == null || jpaProvider.supportsCollectionValueDereference());
}
Program: 168823
Project: 168823
Buggy source:
protected String joinAliasValue(String alias,String field){
  if (jpaProvider.getCollectionValueFunction() != null && field == null) {
    alias=jpaProvider.getCollectionValueFunction() + "String_Node_Str" + alias+ "String_Node_Str";
  }
  if (field == null) {
    return alias;
  }
  return alias + "String_Node_Str" + field;
}

Fixed version (ground truth):
private static String joinAliasValue(JpaProvider provider,String alias,String field){
  if (provider.getCollectionValueFunction() != null && (field == null || provider.supportsCollectionValueDereference())) {
    alias=provider.getCollectionValueFunction() + "String_Node_Str" + alias+ "String_Node_Str";
  }
  if (field == null) {
    return alias;
  }
  return alias + "String_Node_Str" + field;
}
Program: 168824
Project: 168824
Buggy source:
protected static String staticJoinAliasValue(String alias,String field){
  alias=STATIC_JPA_PROVIDER.getCollectionValueFunction() != null ? STATIC_JPA_PROVIDER.getCollectionValueFunction() + "String_Node_Str" + alias+ "String_Node_Str" : alias;
  if (field == null) {
    return alias;
  }
  return alias + "String_Node_Str" + field;
}

Fixed version (ground truth):
protected static String staticJoinAliasValue(String alias,String field){
  return joinAliasValue(STATIC_JPA_PROVIDER,alias,field);
}
Program: 168825
Project: 168825
Buggy source:
private boolean needsValueFunction(PathExpression expression){
  JoinNode baseNode=(JoinNode)expression.getBaseNode();
  return !expression.isCollectionKeyPath() && baseNode.getParentTreeNode() != null && baseNode.getParentTreeNode().isMap();
}

Fixed version (ground truth):
private boolean needsValueFunction(PathExpression expression){
  JoinNode baseNode=(JoinNode)expression.getBaseNode();
  return !expression.isCollectionKeyPath() && baseNode.getParentTreeNode() != null && baseNode.getParentTreeNode().isMap() && expression.getField() == null;
}
Program: 168826
Project: 168826
Buggy source:
protected String joinAliasValue(String alias,String field){
  alias=jpaProvider.getCollectionValueFunction() != null ? jpaProvider.getCollectionValueFunction() + "String_Node_Str" + alias+ "String_Node_Str" : alias;
  if (field == null) {
    return alias;
  }
  return alias + "String_Node_Str" + field;
}

Fixed version (ground truth):
protected String joinAliasValue(String alias,String field){
  if (jpaProvider.getCollectionValueFunction() != null && field == null) {
    alias=jpaProvider.getCollectionValueFunction() + "String_Node_Str" + alias+ "String_Node_Str";
  }
  if (field == null) {
    return alias;
  }
  return alias + "String_Node_Str" + field;
}
Program: 168827
Project: 168827
Buggy source:
@Test @Category({NoDB2.class,NoMSSQL.class,NoOracle.class}) public void testSizeTransformWithImplicitParameterGroupBy2(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str").selectCase().when("String_Node_Str").lt(2l).thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str");
  final String expected="String_Node_Str" + function("String_Node_Str","String_Node_Str") + "String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test @Category({NoDB2.class,NoMSSQL.class,NoOracle.class}) public void testSizeTransformWithImplicitParameterGroupBy2(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str").selectCase().when("String_Node_Str").lt(2l).thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str");
  final String expected="String_Node_Str" + function("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ groupByPathExpressions("String_Node_Str","String_Node_Str");
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}
Program: 168828
Project: 168828
Buggy source:
@Test public void testGroupByFunction(){
  CriteriaBuilder<Document> cb=cbf.create(em,Document.class,"String_Node_Str");
  cb.select("String_Node_Str").select("String_Node_Str","String_Node_Str").where("String_Node_Str").in(2013,2014,2015).groupBy("String_Node_Str").orderByAsc("String_Node_Str");
  String expected="String_Node_Str" + function("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ function("String_Node_Str","String_Node_Str")+ "String_Node_Str"+ listParameter("String_Node_Str")+ "String_Node_Str"+ "String_Node_Str"+ groupBy("String_Node_Str",function("String_Node_Str","String_Node_Str"),renderNullPrecedenceGroupBy(function("String_Node_Str","String_Node_Str")))+ "String_Node_Str"+ renderNullPrecedence("String_Node_Str",function("String_Node_Str","String_Node_Str"),"String_Node_Str","String_Node_Str");
  assertEquals(expected,cb.getQueryString());
  cb.getResultList();
}

Fixed version (ground truth):
@Test public void testGroupByFunction(){
  CriteriaBuilder<Document> cb=cbf.create(em,Document.class,"String_Node_Str");
  cb.select("String_Node_Str").select("String_Node_Str","String_Node_Str").where("String_Node_Str").in(2013,2014,2015).groupBy("String_Node_Str").orderByAsc("String_Node_Str");
  String expected="String_Node_Str" + function("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ function("String_Node_Str","String_Node_Str")+ "String_Node_Str"+ listParameter("String_Node_Str")+ "String_Node_Str"+ "String_Node_Str"+ groupBy("String_Node_Str",groupByPathExpressions(function("String_Node_Str","String_Node_Str"),"String_Node_Str"),renderNullPrecedenceGroupBy(groupByPathExpressions(function("String_Node_Str","String_Node_Str"),"String_Node_Str")))+ "String_Node_Str"+ renderNullPrecedence("String_Node_Str",function("String_Node_Str","String_Node_Str"),"String_Node_Str","String_Node_Str");
  assertEquals(expected,cb.getQueryString());
  cb.getResultList();
}
Program: 168829
Project: 168829
Buggy source:
@Test public void testOrderByFunctionExpression(){
  PaginatedCriteriaBuilder<String> criteria=cbf.create(em,String.class).from(Document.class,"String_Node_Str").select("String_Node_Str","String_Node_Str").orderByAsc("String_Node_Str").orderByAsc("String_Node_Str").page(0,1);
  String expectedQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + groupBy("String_Node_Str",renderNullPrecedenceGroupBy("String_Node_Str"),renderNullPrecedenceGroupBy("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");
  assertEquals(expectedQuery,criteria.getPageIdQueryString());
}

Fixed version (ground truth):
@Test public void testOrderByFunctionExpression(){
  PaginatedCriteriaBuilder<String> criteria=cbf.create(em,String.class).from(Document.class,"String_Node_Str").select("String_Node_Str","String_Node_Str").orderByAsc("String_Node_Str").orderByAsc("String_Node_Str").page(0,1);
  String expectedQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + groupBy("String_Node_Str",renderNullPrecedenceGroupBy(groupByPathExpressions("String_Node_Str","String_Node_Str")),renderNullPrecedenceGroupBy("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");
  assertEquals(expectedQuery,criteria.getPageIdQueryString());
}
Program: 168830
Project: 168830
Buggy source:
@Test @Category({NoDatanucleus.class}) public void testSelectMinimalTrimFunction(){
  CriteriaBuilder<String> cb=cbf.create(em,String.class).from(Document.class).select("String_Node_Str").select("String_Node_Str");
  assertEquals("String_Node_Str" + function("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",cb.getQueryString());
  cb.getResultList();
}

Fixed version (ground truth):
@Test @Category({NoDatanucleus.class}) public void testSelectMinimalTrimFunction(){
  CriteriaBuilder<String> cb=cbf.create(em,String.class).from(Document.class).select("String_Node_Str").select("String_Node_Str");
  assertEquals("String_Node_Str" + function("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ groupByPathExpressions("String_Node_Str","String_Node_Str"),cb.getQueryString());
  cb.getResultList();
}
Program: 168831
Project: 168831
Buggy source:
public Set<Expression> extractGroupByExpressions(Expression expression){
  clear();
  collect=expression instanceof Predicate;
  if (expression.accept(this)) {
    return expressions;
  }
  return Collections.singleton(expression);
}

Fixed version (ground truth):
public Set<Expression> extractGroupByExpressions(Expression expression){
  clear();
  if (!dbmsDialect.supportsGroupByExpressionInHavingMatching()) {
    expression.accept(new VisitorAdapter(){
      @Override public void visit(      FunctionExpression expression){
        if (expression instanceof AggregateExpression || (treatSizeAsAggregate && com.blazebit.persistence.impl.util.ExpressionUtils.isSizeFunction(expression))) {
          return;
        }
        super.visit(expression);
      }
      @Override public void visit(      SubqueryExpression expression){
        GroupByExpressionGatheringVisitor.this.visit(expression);
      }
      @Override public void visit(      PathExpression expression){
        expressions.add(expression);
      }
      @Override public void visit(      TreatExpression expression){
        expressions.add(expression);
      }
      @Override public void visit(      PropertyExpression expression){
        expressions.add(expression);
      }
    }
);
    return expressions;
  }
  collect=expression instanceof Predicate;
  if (expression.accept(this)) {
    return expressions;
  }
  return Collections.singleton(expression);
}
Program: 168833
Project: 168833
Buggy source:
@Test public void testHavingAndCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingAnd().havingCase().whenAnd().and("String_Node_Str").eqExpression("String_Node_Str").and("String_Node_Str").ltExpression("String_Node_Str").thenExpression("String_Node_Str").when("String_Node_Str").eqExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").eqExpression("String_Node_Str").endAnd().endOr();
  String expected="String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test public void testHavingAndCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingAnd().havingCase().whenAnd().and("String_Node_Str").eqExpression("String_Node_Str").and("String_Node_Str").ltExpression("String_Node_Str").thenExpression("String_Node_Str").when("String_Node_Str").eqExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").eqExpression("String_Node_Str").endAnd().endOr();
  String expected="String_Node_Str" + "String_Node_Str" + groupByPathExpressions("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}
Program: 168834
Project: 168834
Buggy source:
@Test public void testHavingSimpleCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingSimpleCase("String_Node_Str").when("String_Node_Str","String_Node_Str").otherwise("String_Node_Str").eqExpression("String_Node_Str");
  String expected="String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test public void testHavingSimpleCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingSimpleCase("String_Node_Str").when("String_Node_Str","String_Node_Str").otherwise("String_Node_Str").eqExpression("String_Node_Str");
  String expected="String_Node_Str" + "String_Node_Str" + groupByPathExpressions("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}
Program: 168835
Project: 168835
Buggy source:
@Test public void testHavingCase1(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingCase().when("String_Node_Str").geExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").eqExpression("String_Node_Str");
  String expected="String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test public void testHavingCase1(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingCase().when("String_Node_Str").geExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").eqExpression("String_Node_Str");
  String expected="String_Node_Str" + "String_Node_Str" + groupByPathExpressions("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}
Program: 168836
Project: 168836
Buggy source:
@Test public void testHavingOrSimpleCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingSimpleCase("String_Node_Str").when("String_Node_Str","String_Node_Str").when("String_Node_Str","String_Node_Str").otherwise("String_Node_Str").eqExpression("String_Node_Str").endOr();
  String expected="String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test public void testHavingOrSimpleCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingSimpleCase("String_Node_Str").when("String_Node_Str","String_Node_Str").when("String_Node_Str","String_Node_Str").otherwise("String_Node_Str").eqExpression("String_Node_Str").endOr();
  String expected="String_Node_Str" + "String_Node_Str" + groupByPathExpressions("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}
Program: 168837
Project: 168837
Buggy source:
@Test public void testHavingAndSimpleCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingAnd().havingSimpleCase("String_Node_Str").when("String_Node_Str","String_Node_Str").when("String_Node_Str","String_Node_Str").otherwise("String_Node_Str").eqExpression("String_Node_Str").endAnd().endOr();
  String expected="String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test public void testHavingAndSimpleCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingAnd().havingSimpleCase("String_Node_Str").when("String_Node_Str","String_Node_Str").when("String_Node_Str","String_Node_Str").otherwise("String_Node_Str").eqExpression("String_Node_Str").endAnd().endOr();
  String expected="String_Node_Str" + "String_Node_Str" + groupByPathExpressions("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}
Program: 168838
Project: 168838
Buggy source:
@Test @Category(NoMySQL.class) public void testHavingPropertyExpression(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").having("String_Node_Str").gt(0L);
  assertEquals("String_Node_Str",criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test @Category(NoMySQL.class) public void testHavingPropertyExpression(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").having("String_Node_Str").gt(0L);
  assertEquals("String_Node_Str" + groupByPathExpressions("String_Node_Str","String_Node_Str") + "String_Node_Str",criteria.getQueryString());
  criteria.getResultList();
}
Program: 168839
Project: 168839
Buggy source:
@Test public void testHavingOrCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingCase().whenAnd().and("String_Node_Str").eqExpression("String_Node_Str").and("String_Node_Str").ltExpression("String_Node_Str").thenExpression("String_Node_Str").when("String_Node_Str").eqExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").eqExpression("String_Node_Str").endOr();
  String expected="String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}

Fixed version (ground truth):
@Test public void testHavingOrCase(){
  CriteriaBuilder<Long> criteria=cbf.create(em,Long.class).from(Document.class,"String_Node_Str").select("String_Node_Str");
  criteria.groupBy("String_Node_Str").havingOr().havingCase().whenAnd().and("String_Node_Str").eqExpression("String_Node_Str").and("String_Node_Str").ltExpression("String_Node_Str").thenExpression("String_Node_Str").when("String_Node_Str").eqExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").eqExpression("String_Node_Str").endOr();
  String expected="String_Node_Str" + "String_Node_Str" + groupByPathExpressions("String_Node_Str","String_Node_Str") + "String_Node_Str"+ "String_Node_Str";
  assertEquals(expected,criteria.getQueryString());
  criteria.getResultList();
}
Program: 168840
Project: 168840
Buggy source:
@Test public void testSelectAggregateEntitySelect(){
  CriteriaBuilder<Tuple> cb=cbf.create(em,Tuple.class).from(Document.class,"String_Node_Str").selectCase().when("String_Node_Str").gtExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").select("String_Node_Str").orderByDesc("String_Node_Str");
  String objectQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + groupBy("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",renderNullPrecedenceGroupBy("String_Node_Str")) + "String_Node_Str"+ renderNullPrecedence("String_Node_Str","String_Node_Str","String_Node_Str");
  assertEquals(objectQuery,cb.getQueryString());
  cb.getResultList();
}

Fixed version (ground truth):
@Test public void testSelectAggregateEntitySelect(){
  CriteriaBuilder<Tuple> cb=cbf.create(em,Tuple.class).from(Document.class,"String_Node_Str").selectCase().when("String_Node_Str").gtExpression("String_Node_Str").thenExpression("String_Node_Str").otherwiseExpression("String_Node_Str").select("String_Node_Str").orderByDesc("String_Node_Str");
  String objectQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + groupBy("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",renderNullPrecedenceGroupBy("String_Node_Str")) + "String_Node_Str"+ renderNullPrecedence("String_Node_Str","String_Node_Str","String_Node_Str");
  assertEquals(objectQuery,cb.getQueryString());
  cb.getResultList();
}