nus-yam/ex-repair huggingface dataset:
Program: 169030
Project: 169030
Buggy source:
/** 
 * Like   {@link QueryBuilder#page(int,int)} but additionally uses key set pagination when possible.Beware that keyset pagination should not be used as a direct replacement for offset pagination. Since entries that have a lower rank than some keyset might be added or removed, the calculations for the firstResult might be wrong. If strict pagination is required, then a keyset should be thrown away when the count of lower ranked items changes to make use of offset pagination again. <p> Key set pagination is possible if and only if the following conditions are met: <ul> <li>This keyset reference values fit the order by expressions of this query builder AND</li> <li> {@link KeysetPage#getMaxResults()} and <code>maxResults</code> evaluate to the same value AND</li><li>One of the following conditions is met: <ul> <li>The absolute value of  {@link KeysetPage#getFirstResults()}<code> - firstResult</code> is 0</li> <li>The absolute value of   {@link KeysetPage#getFirstResults()}<code> - firstResult</code> is equal to the value of <code>maxResults</code></li> </ul> </li> </ul> </p>
 * @param keysetPage  The key set from a previous result, may be null
 * @param firstResult The position of the first result to retrieve, numbered from 0
 * @param maxResults  The maximum number of results to retrieve
 * @return This query builder as paginated query builder
 * @see PagedList#getKeysetPage()
 */
public PaginatedCriteriaBuilder<T> page(KeysetPage keysetPage,int firstResult,int maxResults);

Fixed version (ground truth):
/** 
 * Like   {@link QueryBuilder#page(int,int)} but additionally uses key set pagination when possible.Beware that keyset pagination should not be used as a direct replacement for offset pagination. Since entries that have a lower rank than some keyset might be added or removed, the calculations for the firstResult might be wrong. If strict pagination is required, then a keyset should be thrown away when the count of lower ranked items changes to make use of offset pagination again. <p> Key set pagination is possible if and only if the following conditions are met: <ul> <li>This keyset reference values fit the order by expressions of this query builder AND</li> <li> {@link KeysetPage#getMaxResults()} and <code>maxResults</code> evaluate to the same value AND</li><li>One of the following conditions is met: <ul> <li>The absolute value of  {@link KeysetPage#getFirstResult()}<code> - firstResult</code> is 0</li> <li>The absolute value of   {@link KeysetPage#getFirstResult()}<code> - firstResult</code> is equal to the value of <code>maxResults</code></li> </ul> </li> </ul> </p>
 * @param keysetPage  The key set from a previous result, may be null
 * @param firstResult The position of the first result to retrieve, numbered from 0
 * @param maxResults  The maximum number of results to retrieve
 * @return This query builder as paginated query builder
 * @see PagedList#getKeysetPage()
 */
public PaginatedCriteriaBuilder<T> page(KeysetPage keysetPage,int firstResult,int maxResults);
Program: 169031
Project: 169031
Buggy source:
/** 
 * Like   {@link RestrictionBuilder#eq(java.lang.String) } but the result is wrapped in a NOT predicate.
 * @param expression The expression on the right hand side
 * @return The quantifiable binary predicate builder
 */
public T notEqExpression(String expression);

Fixed version (ground truth):
/** 
 * Like   {@link RestrictionBuilder#eqExpression(java.lang.String) } but the result is wrapped in a NOT predicate.
 * @param expression The expression on the right hand side
 * @return The quantifiable binary predicate builder
 */
public T notEqExpression(String expression);
Program: 169032
Project: 169032
Buggy source:
/** 
 * Like   {@link Selectable#selectSubquery(java.lang.String,java.lang.String,java.lang.String)} but without a select alias.
 * @param subqueryAlias The alias for the subquery which will be replaced by the actual subquery
 * @param expression    The expression which will be added as select item
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<? extends SelectBuilder<T,?>> selectSubquery(String subqueryAlias,String expression);

Fixed version (ground truth):
/** 
 * Like   {@link SelectBuilder#selectSubquery(java.lang.String,java.lang.String,java.lang.String)} but without a select alias.
 * @param subqueryAlias The alias for the subquery which will be replaced by the actual subquery
 * @param expression    The expression which will be added as select item
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<? extends SelectBuilder<T,?>> selectSubquery(String subqueryAlias,String expression);
Program: 169033
Project: 169033
Buggy source:
/** 
 * Like   {@link BaseQueryBuilder#orderByFunction(java.lang.String,boolean,boolean) } but with <code>ascending</code> set to false.
 * @param expression The expression for the order by clause
 * @param nullFirst  Wether null elements should be ordered first or not.
 * @return The query builder for chaining calls
 */
public T orderByFunctionDesc(String expression,boolean nullFirst);

Fixed version (ground truth):
/** 
 * Like   {@link OrderByBuilderExperimental#orderByFunction(java.lang.String,boolean,boolean) } but with <code>ascending</code> set to false.
 * @param expression The expression for the order by clause
 * @param nullFirst  Wether null elements should be ordered first or not.
 * @return The query builder for chaining calls
 */
public T orderByFunctionDesc(String expression,boolean nullFirst);
Program: 169034
Project: 169034
Buggy source:
/** 
 * Like   {@link BaseQueryBuilder#orderByFunction(java.lang.String,boolean,boolean) } but with <code>ascending</code> set to true.
 * @param expression The expression for the order by clause
 * @param nullFirst  Wether null elements should be ordered first or not.
 * @return The query builder for chaining calls
 */
public T orderByFunctionAsc(String expression,boolean nullFirst);

Fixed version (ground truth):
/** 
 * Like   {@link OrderByBuilderExperimental#orderByFunction(java.lang.String,boolean,boolean) } but with <code>ascending</code> set to true.
 * @param expression The expression for the order by clause
 * @param nullFirst  Wether null elements should be ordered first or not.
 * @return The query builder for chaining calls
 */
public T orderByFunctionAsc(String expression,boolean nullFirst);
Program: 169035
Project: 169035
Buggy source:
@Override public Expression visitEnum_literal(JPQLSelectExpressionParser.Enum_literalContext ctx){
  return new FooExpression(ctx.path().accept(this).toString());
}

Fixed version (ground truth):
@Override public Expression visitEnum_literal(JPQLSelectExpressionParser.Enum_literalContext ctx){
  return new LiteralExpression("String_Node_Str",ctx.path().accept(this).toString());
}
Program: 169036
Project: 169036
Buggy source:
@Override public Expression visitEntity_type_literal(JPQLSelectExpressionParser.Entity_type_literalContext ctx){
  return new FooExpression(ctx.identifier().getText());
}

Fixed version (ground truth):
@Override public Expression visitEntity_type_literal(JPQLSelectExpressionParser.Entity_type_literalContext ctx){
  return new LiteralExpression("String_Node_Str",ctx.identifier().getText());
}
Program: 169037
Project: 169037
Buggy source:
@Test public void testEnumCompare(){
  GeneralCaseExpression result=(GeneralCaseExpression)parse("String_Node_Str");
  GeneralCaseExpression expected=new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new EqPredicate(path("String_Node_Str"),foo("String_Node_Str")),foo("String_Node_Str"))),foo("String_Node_Str"));
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testEnumCompare(){
  GeneralCaseExpression result=(GeneralCaseExpression)parse("String_Node_Str");
  GeneralCaseExpression expected=new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new EqPredicate(path("String_Node_Str"),literal("String_Node_Str","String_Node_Str")),foo("String_Node_Str"))),foo("String_Node_Str"));
  assertEquals(expected,result);
}
Program: 169038
Project: 169038
Buggy source:
@Test public void testEtityTypeCompare(){
  GeneralCaseExpression result=(GeneralCaseExpression)parse("String_Node_Str");
  GeneralCaseExpression expected=new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new EqPredicate(function("String_Node_Str",path("String_Node_Str")),foo("String_Node_Str")),foo("String_Node_Str"))),foo("String_Node_Str"));
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testEtityTypeCompare(){
  GeneralCaseExpression result=(GeneralCaseExpression)parse("String_Node_Str");
  GeneralCaseExpression expected=new GeneralCaseExpression(Arrays.asList(new WhenClauseExpression(new EqPredicate(function("String_Node_Str",path("String_Node_Str")),literal("String_Node_Str","String_Node_Str")),foo("String_Node_Str"))),foo("String_Node_Str"));
  assertEquals(expected,result);
}
Program: 169039
Project: 169039
Buggy source:
@Test public void testEnumLiteral(){
  FooExpression result=(FooExpression)parse("String_Node_Str");
  assertEquals(new FooExpression("String_Node_Str"),result);
}

Fixed version (ground truth):
@Test public void testEnumLiteral(){
  LiteralExpression result=(LiteralExpression)parse("String_Node_Str");
  assertEquals(new LiteralExpression("String_Node_Str","String_Node_Str"),result);
}
Program: 169040
Project: 169040
Buggy source:
@Test public void testEntityTypeLiteral(){
  FooExpression result=(FooExpression)parse("String_Node_Str");
  assertEquals(new FooExpression("String_Node_Str"),result);
}

Fixed version (ground truth):
@Test public void testEntityTypeLiteral(){
  LiteralExpression result=(LiteralExpression)parse("String_Node_Str");
  assertEquals(new LiteralExpression("String_Node_Str","String_Node_Str"),result);
}
Program: 169041
Project: 169041
Buggy source:
private static String getPrefixedExpression(EntityViewManagerImpl evm,List<String> subviewPrefixParts,String mappingExpression){
  if (subviewPrefixParts != null && subviewPrefixParts.size() > 0) {
    Expression expr=evm.getExpressionFactory().createSimpleExpression(mappingExpression);
    expr.accept(new SubviewPrefixExpressionVisitor(subviewPrefixParts));
    SimpleQueryGenerator generator=new SimpleQueryGenerator();
    StringBuilder sb=new StringBuilder();
    generator.setQueryBuffer(sb);
    expr.accept(generator);
    return sb.toString();
  }
  return mappingExpression;
}

Fixed version (ground truth):
private static String getPrefixedExpression(EntityViewManagerImpl evm,List<String> subviewPrefixParts,String mappingExpression){
  if (subviewPrefixParts != null && subviewPrefixParts.size() > 0) {
    Expression expr=evm.getExpressionFactory().createSimpleExpression(mappingExpression);
    SimpleQueryGenerator generator=new PrefixingQueryGenerator(subviewPrefixParts);
    StringBuilder sb=new StringBuilder();
    generator.setQueryBuffer(sb);
    expr.accept(generator);
    return sb.toString();
  }
  return mappingExpression;
}
Program: 169042
Project: 169042
Buggy source:
private String getJoinAlias(ArrayExpression expr){
  StringBuilder sb=new StringBuilder(expr.getBase().toString());
  Expression indexExpr=expr.getIndex();
  if (indexExpr instanceof ParameterExpression) {
    ParameterExpression indexParamExpr=(ParameterExpression)indexExpr;
    sb.append('_');
    sb.append(indexParamExpr.getName());
  }
 else   if (indexExpr instanceof PathExpression) {
    PathExpression indexPathExpr=(PathExpression)indexExpr;
    sb.append('_');
    sb.append(((JoinNode)indexPathExpr.getBaseNode()).getAliasInfo().getAlias());
    if (indexPathExpr.getField() != null) {
      sb.append('_');
      sb.append(indexPathExpr.getField());
    }
  }
 else {
    sb.append('_');
    sb.append(indexExpr.toString().replaceAll("String_Node_Str","String_Node_Str"));
  }
  return sb.toString();
}

Fixed version (ground truth):
private String getJoinAlias(ArrayExpression expr){
  StringBuilder sb=new StringBuilder(expr.getBase().toString());
  Expression indexExpr=expr.getIndex();
  if (indexExpr instanceof ParameterExpression) {
    ParameterExpression indexParamExpr=(ParameterExpression)indexExpr;
    sb.append('_');
    sb.append(indexParamExpr.getName());
  }
 else   if (indexExpr instanceof PathExpression) {
    PathExpression indexPathExpr=(PathExpression)indexExpr;
    sb.append('_');
    sb.append(((JoinNode)indexPathExpr.getBaseNode()).getAliasInfo().getAlias());
    if (indexPathExpr.getField() != null) {
      sb.append('_');
      sb.append(indexPathExpr.getField().replaceAll("String_Node_Str","String_Node_Str"));
    }
  }
 else {
    sb.append('_');
    sb.append(indexExpr.toString().replaceAll("String_Node_Str","String_Node_Str"));
  }
  return sb.toString();
}
Program: 169043
Project: 169043
Buggy source:
private Class<?> resolveType(Class<?> concreteClass,java.lang.reflect.Type type){
  if (type instanceof ParameterizedType) {
    return (Class<?>)((ParameterizedType)type).getRawType();
  }
 else   if (type instanceof TypeVariable) {
    return resolveType(concreteClass,((TypeVariable<?>)type).getBounds()[0]);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + type);
  }
}

Fixed version (ground truth):
private Class<?> resolveType(Class<?> concreteClass,java.lang.reflect.Type type){
  if (type instanceof Class<?>) {
    return (Class<?>)type;
  }
 else   if (type instanceof ParameterizedType) {
    return (Class<?>)((ParameterizedType)type).getRawType();
  }
 else   if (type instanceof TypeVariable) {
    return resolveType(concreteClass,((TypeVariable<?>)type).getBounds()[0]);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + type);
  }
}
Program: 169044
Project: 169044
Buggy source:
@Override protected Class<?>[] getEntityClasses(){
  return new Class<?>[]{Document.class,Version.class,Person.class,Workflow.class};
}

Fixed version (ground truth):
@Override protected Class<?>[] getEntityClasses(){
  return new Class<?>[]{Document.class,Version.class,Person.class,Workflow.class,IntIdEntity.class};
}
Program: 169045
Project: 169045
Buggy source:
@Override public SQLExpression getExpression(SQLExpression expr,List<SQLExpression> args){
  List<String> newArgs=new ArrayList<String>(args.size());
  for (int i=0; i < args.size(); i++) {
    newArgs.add(args.get(i).toSQLText().toSQL());
  }
  return new NumericExpression(stmt,getMappingForClass(long.class),function.render(newArgs));
}

Fixed version (ground truth):
@Override public SQLExpression getExpression(SQLExpression expr,List<SQLExpression> args){
  List<String> newArgs=new ArrayList<String>(args.size());
  for (int i=0; i < args.size(); i++) {
    newArgs.add(args.get(i).toSQLText().toSQL());
  }
  return null;
}
Program: 169046
Project: 169046
Buggy source:
Set<String> buildGroupByClauses(){
  if (orderByInfos.isEmpty()) {
    return Collections.EMPTY_SET;
  }
  Set<String> groupByClauses=new HashSet<String>();
  Iterator<OrderByInfo> iter=orderByInfos.iterator();
  OrderByInfo orderByInfo;
  while (iter.hasNext()) {
    StringBuilder sb=StringBuilderProvider.getEmptyStringBuilder();
    queryGenerator.setQueryBuffer(sb);
    orderByInfo=iter.next();
    String potentialSelectAlias=orderByInfo.getExpression().toString();
    AliasInfo aliasInfo=aliasManager.getAliasInfo(potentialSelectAlias);
    if (aliasInfo != null && aliasInfo instanceof SelectInfo) {
      SelectInfo selectInfo=(SelectInfo)aliasInfo;
      String expressionString=selectInfo.getExpression().toString().toUpperCase();
      if (!expressionString.startsWith("String_Node_Str") && !expressionString.startsWith("String_Node_Str") && !expressionString.startsWith("String_Node_Str")&& !expressionString.startsWith("String_Node_Str")&& !expressionString.startsWith("String_Node_Str")) {
        selectInfo.getExpression().accept(queryGenerator);
        groupByClauses.add(sb.toString());
      }
    }
 else {
      orderByInfo.getExpression().accept(queryGenerator);
      groupByClauses.add(sb.toString());
    }
  }
  return groupByClauses;
}

Fixed version (ground truth):
Set<String> buildGroupByClauses(){
  if (orderByInfos.isEmpty()) {
    return Collections.EMPTY_SET;
  }
  Set<String> groupByClauses=new LinkedHashSet<String>();
  Iterator<OrderByInfo> iter=orderByInfos.iterator();
  OrderByInfo orderByInfo;
  while (iter.hasNext()) {
    StringBuilder sb=StringBuilderProvider.getEmptyStringBuilder();
    queryGenerator.setQueryBuffer(sb);
    orderByInfo=iter.next();
    String potentialSelectAlias=orderByInfo.getExpression().toString();
    AliasInfo aliasInfo=aliasManager.getAliasInfo(potentialSelectAlias);
    if (aliasInfo != null && aliasInfo instanceof SelectInfo) {
      SelectInfo selectInfo=(SelectInfo)aliasInfo;
      String expressionString=selectInfo.getExpression().toString().toUpperCase();
      if (!expressionString.startsWith("String_Node_Str") && !expressionString.startsWith("String_Node_Str") && !expressionString.startsWith("String_Node_Str")&& !expressionString.startsWith("String_Node_Str")&& !expressionString.startsWith("String_Node_Str")) {
        selectInfo.getExpression().accept(queryGenerator);
        groupByClauses.add(sb.toString());
      }
    }
 else {
      orderByInfo.getExpression().accept(queryGenerator);
      groupByClauses.add(sb.toString());
    }
  }
  return groupByClauses;
}
Program: 169047
Project: 169047
Buggy source:
private CtConstructor findConstructor(CtClass superCc,MappingConstructor<?> constructor) throws NotFoundException {
  List<ParameterAttribute<?,?>> parameterAttributes=(List<ParameterAttribute<?,?>>)constructor.getParameterAttributes();
  CtClass[] parameterTypes=new CtClass[parameterAttributes.size()];
  for (int i=0; i < parameterAttributes.size(); i++) {
    parameterTypes[i]=pool.get(parameterAttributes.get(i).getJavaType().getName());
  }
  return superCc.getDeclaredConstructor(parameterTypes);
}

Fixed version (ground truth):
private <T>CtConstructor findConstructor(CtClass superCc,MappingConstructor<T> constructor) throws NotFoundException {
  List<ParameterAttribute<? super T,?>> parameterAttributes=constructor.getParameterAttributes();
  CtClass[] parameterTypes=new CtClass[parameterAttributes.size()];
  for (int i=0; i < parameterAttributes.size(); i++) {
    parameterTypes[i]=pool.get(parameterAttributes.get(i).getJavaType().getName());
  }
  return superCc.getDeclaredConstructor(parameterTypes);
}
Program: 169048
Project: 169048
Buggy source:
@Test public void testGetConstructorsInterfaceView() throws Exception {
  ViewMetamodel viewMetamodel=getViewMetamodel();
  ViewType<?> viewType=viewMetamodel.view(DocumentViewInterface.class);
  Set<MappingConstructor<?>> constructors=(Set<MappingConstructor<?>>)viewType.getConstructors();
  assertEquals(0,constructors.size());
}

Fixed version (ground truth):
@Test public void testGetConstructorsInterfaceView() throws Exception {
  ViewMetamodel viewMetamodel=getViewMetamodel();
  ViewType<DocumentViewInterface> viewType=viewMetamodel.view(DocumentViewInterface.class);
  Set<MappingConstructor<DocumentViewInterface>> constructors=viewType.getConstructors();
  assertEquals(0,constructors.size());
}
Program: 169049
Project: 169049
Buggy source:
@Test public void testGetConstructorsClassView() throws Exception {
  ViewMetamodel viewMetamodel=getViewMetamodel();
  ViewType<?> viewType=viewMetamodel.view(DocumentViewAbstractClass.class);
  Set<MappingConstructor<?>> constructors=(Set<MappingConstructor<?>>)viewType.getConstructors();
  assertEquals(1,constructors.size());
  assertNotNull(viewType.getConstructor(Long.class,Integer.class));
  assertTrue(constructors.contains(viewType.getConstructor(Long.class,Integer.class)));
}

Fixed version (ground truth):
@Test public void testGetConstructorsClassView() throws Exception {
  ViewMetamodel viewMetamodel=getViewMetamodel();
  ViewType<DocumentViewAbstractClass> viewType=viewMetamodel.view(DocumentViewAbstractClass.class);
  Set<MappingConstructor<DocumentViewAbstractClass>> constructors=viewType.getConstructors();
  assertEquals(1,constructors.size());
  assertNotNull(viewType.getConstructor(Long.class,Integer.class));
  assertTrue(constructors.contains(viewType.getConstructor(Long.class,Integer.class)));
}
Program: 169052
Project: 169052
Buggy source:
/** 
 * Starts a   {@link HavingOrBuilder} which is a predicate consisting only of disjunctiv connected predicates.When the builder finishes, the predicate is added to the parent predicate container represented by the type  {@linkplain X}.
 * @return The or predicate builder for the having clause
 */
public HavingOrBuilder<? extends T> havingOr();

Fixed version (ground truth):
/** 
 * Starts a   {@link HavingOrBuilder} which is a predicate consisting only of disjunctiv connected predicates.When the builder finishes, the predicate is added to the parent predicate container represented by the type  {@linkplain X}.
 * @return The or predicate builder for the having clause
 */
public HavingOrBuilder<T> havingOr();
Program: 169053
Project: 169053
Buggy source:
/** 
 * Starts a   {@link RestrictionBuilder} for a having predicate with the given expression as left hand expression.When the builder finishes, the predicate is added to the parent predicate container represented by the type  {@linkplain T}.
 * @param expression The left hand expression for a having predicate
 * @return The restriction builder for the given expression
 */
public RestrictionBuilder<? extends T> having(String expression);

Fixed version (ground truth):
/** 
 * Starts a   {@link RestrictionBuilder} for a having predicate with the given expression as left hand expression.When the builder finishes, the predicate is added to the parent predicate container represented by the type  {@linkplain T}.
 * @param expression The left hand expression for a having predicate
 * @return The restriction builder for the given expression
 */
public RestrictionBuilder<T> having(String expression);
Program: 169054
Project: 169054
Buggy source:
/** 
 * Starts an exists predicate for the having clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<? extends T> havingNotExists();

Fixed version (ground truth):
/** 
 * Starts an exists predicate for the having clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<T> havingNotExists();
Program: 169055
Project: 169055
Buggy source:
/** 
 * Starts an exists predicate for the having clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<? extends T> havingExists();

Fixed version (ground truth):
/** 
 * Starts an exists predicate for the having clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<T> havingExists();
Program: 169056
Project: 169056
Buggy source:
/** 
 * Starts an exists predicate for the where clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<? extends T> whereExists();

Fixed version (ground truth):
/** 
 * Starts an exists predicate for the where clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<T> whereExists();
Program: 169057
Project: 169057
Buggy source:
/** 
 * Starts a   {@link RestrictionBuilder} for a where predicate with the given expression as left hand expression.When the builder finishes, the predicate is added to the parent predicate container represented by the type  {@linkplain T}.
 * @param expression The left hand expression for a where predicate
 * @return The restriction builder for the given expression
 */
public RestrictionBuilder<? extends T> where(String expression);

Fixed version (ground truth):
/** 
 * Starts a   {@link RestrictionBuilder} for a where predicate with the given expression as left hand expression.When the builder finishes, the predicate is added to the parent predicate container represented by the type  {@linkplain T}.
 * @param expression The left hand expression for a where predicate
 * @return The restriction builder for the given expression
 */
public RestrictionBuilder<T> where(String expression);
Program: 169058
Project: 169058
Buggy source:
/** 
 * Starts an not exists predicate for the where clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<? extends T> whereNotExists();

Fixed version (ground truth):
/** 
 * Starts an not exists predicate for the where clause with a subquery on the right hand side. When the builder finishes, the predicate is added to the parent predicate container represented by the type   {@linkplain T}.
 * @return The subquery initiator for building a subquery
 */
public SubqueryInitiator<T> whereNotExists();
Program: 169059
Project: 169059
Buggy source:
/** 
 * Starts a   {@link WhereOrBuilder} which is a predicate consisting only ofdisjunctiv connected predicates. When the builder finishes, the predicate is added to the parent predicate container represented by the type {@linkplain X}.
 * @return The or predicate builder for the where clause
 */
public WhereOrBuilder<? extends T> whereOr();

Fixed version (ground truth):
/** 
 * Starts a   {@link WhereOrBuilder} which is a predicate consisting only ofdisjunctiv connected predicates. When the builder finishes, the predicate is added to the parent predicate container represented by the type {@linkplain X}.
 * @return The or predicate builder for the where clause
 */
public WhereOrBuilder<T> whereOr();
Program: 169060
Project: 169060
Buggy source:
/** 
 * Starts a having and builder which connects it's predicates with the AND operator. When the builder finishes, the predicate is added to this predicate container as disjunct.
 * @return The having and builder
 */
public HavingAndBuilder<? extends HavingOrBuilder<T>> havingAnd();

Fixed version (ground truth):
/** 
 * Starts a having and builder which connects it's predicates with the AND operator. When the builder finishes, the predicate is added to this predicate container as disjunct.
 * @return The having and builder
 */
public HavingAndBuilder<HavingOrBuilder<T>> havingAnd();
Program: 169061
Project: 169061
Buggy source:
/** 
 * Returns the expressions that should be selected by a   {@link QueryBuilder}.
 * @return The expression that should be selected
 */
public String[] getExpressions();

Fixed version (ground truth):
/** 
 * Returns the expressions that should be selected by a   {@link QueryBuilder}.
 * @return The expression that should be selected
 */
public String[][] getExpressions();
Program: 169062
Project: 169062
Buggy source:
/** 
 * TODO: javadoc
 * @return
 */
public SubqueryBuilder<U> from(Class<?> clazz,String alias);

Fixed version (ground truth):
/** 
 * TODO: javadoc
 * @return
 */
public SubqueryBuilder<T> from(Class<?> clazz,String alias);
Program: 169063
Project: 169063
Buggy source:
@Override public PagedList<T> getResultList(){
  String countQueryString=getPageCountQueryString();
  TypedQuery<Long> countQuery=em.createQuery(countQueryString,Long.class);
  parameterizeQuery(countQuery);
  long totalSize=countQuery.getSingleResult();
  String idQueryString=getPageIdQueryString();
  Query idQuery=em.createQuery(idQueryString);
  parameterizeQuery(idQuery);
  List ids=idQuery.setFirstResult((int)firstRow).setMaxResults((int)pageSize).getResultList();
  parameterManager.addParameterMapping(idParamName,ids);
  PagedList<T> pagedResultList=new PagedListImpl<T>(super.getResultList(),totalSize);
  return pagedResultList;
}

Fixed version (ground truth):
@Override public PagedList<T> getResultList(){
  String countQueryString=getPageCountQueryString();
  TypedQuery<Long> countQuery=em.createQuery(countQueryString,Long.class);
  parameterizeQuery(countQuery);
  long totalSize=countQuery.getSingleResult();
  if (totalSize == 0L) {
    return new PagedListImpl<T>(totalSize);
  }
  String idQueryString=getPageIdQueryString();
  Query idQuery=em.createQuery(idQueryString);
  parameterizeQuery(idQuery);
  List ids=idQuery.setFirstResult((int)firstRow).setMaxResults((int)pageSize).getResultList();
  if (ids.isEmpty()) {
    return new PagedListImpl<T>(totalSize);
  }
  parameterManager.addParameterMapping(idParamName,ids);
  PagedList<T> pagedResultList=new PagedListImpl<T>(super.getResultList(),totalSize);
  return pagedResultList;
}
Program: 169064
Project: 169064
Buggy source:
@Override public BaseQueryBuilder<RestrictionBuilder<? extends HavingOrBuilder<T>>> havingExists(){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
@Override public SubqueryInitiator<HavingOrBuilderImpl<RestrictionBuilder<? extends HavingOrBuilder<T>>>> havingExists(){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 169066
Project: 169066
Buggy source:
@Override public T notIn(List<?> values){
  if (values == null)   throw new NullPointerException();
  return chain(new NotPredicate(new InPredicate(leftExpression,new ParameterExpression(values))));
}

Fixed version (ground truth):
@Override public SubqueryBuilder<T> notIn(){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 169067
Project: 169067
Buggy source:
@Override public T in(List<?> values){
  if (values == null)   throw new NullPointerException();
  return chain(new InPredicate(leftExpression,new ParameterExpression(values)));
}

Fixed version (ground truth):
@Override public SubqueryBuilder<T> in(){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 169068
Project: 169068
Buggy source:
@Override public BinaryPredicateBuilder<T> all(){
  this.quantifier=PredicateQuantifier.ALL;
  return this;
}

Fixed version (ground truth):
@Override public SubqueryBuilder<T> all(){
  this.quantifier=PredicateQuantifier.ALL;
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 169069
Project: 169069
Buggy source:
@Override public BinaryPredicateBuilder<T> any(){
  this.quantifier=PredicateQuantifier.ANY;
  return this;
}

Fixed version (ground truth):
@Override public SubqueryBuilder<T> any(){
  this.quantifier=PredicateQuantifier.ANY;
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 169070
Project: 169070
Buggy source:
/** 
 * Process Group By queries results
 */
private void processAggregation(ProjectParsed queryData,ResultSet resultSet,SearchResponse response) throws ExecutionException {
  Map<Selector,String> alias=returnAlias(queryData);
  for (  Aggregation aggregation : response.getAggregations()) {
    InternalTerms terms=(InternalTerms)aggregation;
    processTermAggregation(queryData,resultSet,alias,terms);
  }
  if (queryData.getOrderBy() != null && (queryData.getOrderBy().getIds().size() > 1 || (queryData.getSelect().isDistinct() && queryData.getSelect().getColumnMap().size() > 1) || queryData.getGroupBy().getIds().size() > 1)) {
    List<OrderByClause> fields=queryData.getOrderBy().getIds();
    Collections.sort(resultSet.getRows(),new RowSorter(fields));
  }
  if (queryData.getLimit() != null) {
    int limit=queryData.getLimit().getLimit();
    if (resultSet.getRows().size() > limit) {
      List<Row> limitedResult=resultSet.getRows().subList(0,limit);
      resultSet.setRows(new ArrayList<>(limitedResult));
    }
  }
}

Fixed version (ground truth):
/** 
 * Process Group By queries results
 */
private void processAggregation(ProjectParsed queryData,ResultSet resultSet,SearchResponse response) throws ExecutionException {
  Map<Selector,String> alias=returnAlias(queryData);
  for (  Aggregation aggregation : response.getAggregations()) {
    InternalTerms terms=(InternalTerms)aggregation;
    processTermAggregation(queryData,resultSet,alias,terms);
  }
  if (queryData.getOrderBy() != null && (queryData.getOrderBy().getIds().size() > 1 || (queryData.getSelect().isDistinct() && queryData.getSelect().getColumnMap().size() > 1) || (queryData.getGroupBy() != null && queryData.getGroupBy().getIds().size() > 1))) {
    List<OrderByClause> fields=queryData.getOrderBy().getIds();
    Collections.sort(resultSet.getRows(),new RowSorter(fields));
  }
  if (queryData.getLimit() != null) {
    int limit=queryData.getLimit().getLimit();
    if (resultSet.getRows().size() > limit) {
      List<Row> limitedResult=resultSet.getRows().subList(0,limit);
      resultSet.setRows(new ArrayList<>(limitedResult));
    }
  }
}
Program: 169071
Project: 169071
Buggy source:
/** 
 * This method execute a query in elasticSearch.
 * @param elasticClient        the elasticSearch Client.
 * @param actionRequestBuilder the query to execute.
 * @param queryData            the queryData.
 * @return the query result.
 */
public QueryResult executeQuery(Client elasticClient,ActionRequestBuilder actionRequestBuilder,ProjectParsed queryData) throws ExecutionException {
  QueryResult queryResult=null;
  SearchRequestBuilder requestBuilder=(SearchRequestBuilder)actionRequestBuilder;
  try {
    ResultSet resultSet=new ResultSet();
    SearchResponse response=((SearchRequestBuilder)requestBuilder).execute().actionGet();
    resultSet.setColumnMetadata(crossdatadataCreator.createColumnMetadata(queryData));
    if (queryData.getGroupBy() != null && !queryData.getGroupBy().getIds().isEmpty()) {
      processAggregation(queryData,resultSet,response);
    }
 else     if (SelectorUtils.hasFunction(queryData.getSelect().getColumnMap(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
      processAggregationFucntion(queryData,resultSet,response);
    }
 else {
      processResults(queryData,resultSet,response);
    }
    queryResult=QueryResult.createQueryResult(resultSet,0,true);
  }
 catch (  IndexMissingException e) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + e.getMessage());
    }
    queryResult=QueryResult.createQueryResult(new ResultSet(),0,true);
  }
  return queryResult;
}

Fixed version (ground truth):
/** 
 * This method execute a query in elasticSearch.
 * @param elasticClient        the elasticSearch Client.
 * @param actionRequestBuilder the query to execute.
 * @param queryData            the queryData.
 * @return the query result.
 */
public QueryResult executeQuery(Client elasticClient,ActionRequestBuilder actionRequestBuilder,ProjectParsed queryData) throws ExecutionException {
  QueryResult queryResult;
  SearchRequestBuilder requestBuilder=(SearchRequestBuilder)actionRequestBuilder;
  try {
    ResultSet resultSet=new ResultSet();
    SearchResponse response=requestBuilder.execute().actionGet();
    resultSet.setColumnMetadata(crossdatadataCreator.createColumnMetadata(queryData));
    if (queryData.getGroupBy() != null && !queryData.getGroupBy().getIds().isEmpty()) {
      processAggregation(queryData,resultSet,response);
    }
 else     if (SelectorUtils.hasFunction(queryData.getSelect().getColumnMap(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
      processAggregationFucntion(queryData,resultSet,response);
    }
 else {
      processResults(queryData,resultSet,response);
    }
    queryResult=QueryResult.createQueryResult(resultSet,0,true);
  }
 catch (  IndexMissingException e) {
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + e.getMessage());
    }
    queryResult=QueryResult.createQueryResult(new ResultSet(),0,true);
  }
  return queryResult;
}
Program: 169072
Project: 169072
Buggy source:
private void processSubAggregation(ProjectParsed queryData,List<Aggregation> aggregations,Map<Selector,String> alias,Map<String,Object> fields,ResultSet resultSet) throws ExecutionException {
  for (  Aggregation subAgg : aggregations) {
    if (subAgg instanceof InternalTerms) {
      InternalTerms termsSubAgg=(InternalTerms)subAgg;
      for (      Terms.Bucket subBucker : termsSubAgg.getBuckets()) {
        if (subBucker.getAggregations().iterator().hasNext()) {
          fields.put(termsSubAgg.getName(),geyBucketValue(subBucker));
          processSubAggregation(queryData,subBucker.getAggregations().asList(),alias,fields,resultSet);
          addResult(resultSet,buildRow(queryData,alias,fields));
        }
 else {
          fields.put(termsSubAgg.getName(),geyBucketValue(subBucker));
          addResult(resultSet,buildRow(queryData,alias,fields));
        }
      }
    }
 else     if (subAgg instanceof NumericMetricsAggregation) {
      NumericMetricsAggregation.SingleValue numericAggregation=(NumericMetricsAggregation.SingleValue)subAgg;
      fields.put(subAgg.getName(),numericAggregation.value());
      addResult(resultSet,buildRow(queryData,alias,fields));
    }
  }
}

Fixed version (ground truth):
private void processSubAggregation(ProjectParsed queryData,List<Aggregation> aggregations,Map<Selector,String> alias,Map<String,Object> fields,ResultSet resultSet) throws ExecutionException {
  for (  Aggregation subAgg : aggregations) {
    if (subAgg instanceof InternalTerms) {
      InternalTerms termsSubAgg=(InternalTerms)subAgg;
      for (      Terms.Bucket subBucker : termsSubAgg.getBuckets()) {
        if (subBucker.getAggregations().iterator().hasNext()) {
          fields.put(termsSubAgg.getName(),geyBucketValue(subBucker));
          processSubAggregation(queryData,subBucker.getAggregations().asList(),alias,fields,resultSet);
          addResult(resultSet,buildRow(queryData,alias,fields));
        }
 else {
          fields.put(termsSubAgg.getName(),geyBucketValue(subBucker));
          addResult(resultSet,buildRow(queryData,alias,fields));
        }
      }
      addResult(resultSet,buildRow(queryData,alias,fields));
    }
 else     if (subAgg instanceof NumericMetricsAggregation) {
      NumericMetricsAggregation.SingleValue numericAggregation=(NumericMetricsAggregation.SingleValue)subAgg;
      fields.put(subAgg.getName(),numericAggregation.value());
    }
  }
  addResult(resultSet,buildRow(queryData,alias,fields));
}
Program: 169073
Project: 169073
Buggy source:
/** 
 * Process Group By queries results
 */
private void processAggregation(ProjectParsed queryData,ResultSet resultSet,SearchResponse response) throws ExecutionException {
  Map<Selector,String> alias=returnAlias(queryData);
  for (  Aggregation aggregation : response.getAggregations()) {
    InternalTerms terms=(InternalTerms)aggregation;
    processTermAggregation(queryData,resultSet,alias,terms);
  }
  if (queryData.getOrderBy() != null && !queryData.getOrderBy().getIds().isEmpty()) {
    List<OrderByClause> fields=queryData.getOrderBy().getIds();
    Collections.sort(resultSet.getRows(),new RowSorter(fields));
  }
  if (queryData.getLimit() != null) {
    int limit=queryData.getLimit().getLimit();
    List<Row> limitedResult=resultSet.getRows().subList(0,limit);
    resultSet.setRows(new ArrayList<>(limitedResult));
  }
}

Fixed version (ground truth):
/** 
 * Process Group By queries results
 */
private void processAggregation(ProjectParsed queryData,ResultSet resultSet,SearchResponse response) throws ExecutionException {
  Map<Selector,String> alias=returnAlias(queryData);
  for (  Aggregation aggregation : response.getAggregations()) {
    InternalTerms terms=(InternalTerms)aggregation;
    processTermAggregation(queryData,resultSet,alias,terms);
  }
  if (queryData.getOrderBy() != null && queryData.getOrderBy().getIds().size() > 1) {
    List<OrderByClause> fields=queryData.getOrderBy().getIds();
    Collections.sort(resultSet.getRows(),new RowSorter(fields));
  }
  if (queryData.getLimit() != null) {
    int limit=queryData.getLimit().getLimit();
    if (resultSet.getRows().size() > limit) {
      List<Row> limitedResult=resultSet.getRows().subList(0,limit);
      resultSet.setRows(new ArrayList<>(limitedResult));
    }
  }
}
Program: 169074
Project: 169074
Buggy source:
/** 
 * Method that creates the Filter part of the query.
 * @param queryData the querydata.
 */
private void createFilter(ProjectParsed queryData) throws UnsupportedException, ExecutionException {
  QueryBuilderFactory queryBuilderFactory=new QueryBuilderFactory();
  QueryBuilder queryBuilder=queryBuilderFactory.createBuilder(queryData.getMatchList(),queryData.getFunctionFilters());
  if (!queryData.getFilter().isEmpty()) {
    FilterBuilderCreator filterBuilderCreator=new FilterBuilderCreator();
    FilterBuilder filterBuilder=filterBuilderCreator.createFilterBuilder(queryData.getFilter());
    queryBuilder=QueryBuilders.filteredQuery(queryBuilder,filterBuilder);
  }
  if (!queryData.getDisjunctionList().isEmpty()) {
    FilterBuilderCreator filterBuilderCreator=new FilterBuilderCreator();
    FilterBuilder filterBuilder=filterBuilderCreator.createFilterBuilderForDisjunctions(queryData.getDisjunctionList());
    queryBuilder=QueryBuilders.filteredQuery(queryBuilder,filterBuilder);
  }
  requestBuilder.setQuery(queryBuilder);
}

Fixed version (ground truth):
/** 
 * Method that creates the Filter part of the query.
 * @param queryData the querydata.
 */
private void createFilter(ProjectParsed queryData) throws UnsupportedException, ExecutionException {
  QueryBuilder queryBuilder=new QueryBuilderFactory().createBuilder(queryData.getMatchList(),queryData.getFunctionFilters());
  if (!queryData.getFilter().isEmpty()) {
    FilterBuilder filterBuilder=new FilterBuilderCreator().createFilterBuilder(queryData.getFilter());
    queryBuilder=QueryBuilders.filteredQuery(queryBuilder,filterBuilder);
  }
  if (!queryData.getDisjunctionList().isEmpty()) {
    FilterBuilder filterBuilder=new FilterBuilderCreator().createFilterBuilderForDisjunctions(queryData.getDisjunctionList());
    queryBuilder=QueryBuilders.filteredQuery(queryBuilder,filterBuilder);
  }
  requestBuilder.setQuery(queryBuilder);
}
Program: 169075
Project: 169075
Buggy source:
/** 
 * @param elasticClient the elasticSearch Client.
 * @param queryData     the query representation,
 * @return The searchBuilder.
 * @throws UnsupportedException if the operation is not supported.
 * @throws ExecutionException   if the method fails during execution.
 */
public ActionRequestBuilder buildQuery(Client elasticClient,ProjectParsed queryData) throws UnsupportedException, ExecutionException {
  if (null == elasticClient) {
    throw new ExecutionException("String_Node_Str");
  }
  if (null == queryData) {
    throw new ExecutionException("String_Node_Str");
  }
  createRequestBuilder(elasticClient);
  createProjection(queryData.getProject());
  createFilter(queryData);
  if (isAggregation(queryData)) {
    createNestedTermAggregation(queryData,queryData.getGroupBy().getIds());
  }
 else   if (queryData.getSelect() != null && queryData.getSelect().isDistinct() && !useCardinality(queryData.getSelect())) {
    createNestedTermAggregation(queryData,queryData.getSelect().getColumnMap().keySet());
  }
 else {
    createSelect(queryData.getSelect());
    createSort(queryData.getOrderBy());
    createLimit(queryData.getLimit());
  }
  logQuery();
  return requestBuilder;
}

Fixed version (ground truth):
/** 
 * @param elasticClient the elasticSearch Client.
 * @param queryData     the query representation,
 * @return The searchBuilder.
 * @throws UnsupportedException if the operation is not supported.
 * @throws ExecutionException   if the method fails during execution.
 */
public ActionRequestBuilder buildQuery(Client elasticClient,ProjectParsed queryData) throws UnsupportedException, ExecutionException {
  if (null == elasticClient) {
    throw new ExecutionException("String_Node_Str");
  }
  if (null == queryData) {
    throw new ExecutionException("String_Node_Str");
  }
  createRequestBuilder(elasticClient);
  createProjection(queryData.getProject());
  createFilter(queryData);
  if (isAggregation(queryData)) {
    createNestedTermAggregation(queryData,queryData.getGroupBy().getIds());
  }
 else   if (isDistinctAggregation(queryData)) {
    createNestedTermAggregation(queryData,queryData.getSelect().getColumnMap().keySet());
  }
 else {
    createSelect(queryData.getSelect());
    createSort(queryData.getOrderBy());
    createLimit(queryData.getLimit());
  }
  logQuery();
  return requestBuilder;
}
Program: 169079
Project: 169079
Buggy source:
/** 
 * Creates the AggregationBuilder for a GroupBy or a Distinct
 */
private AggregationBuilder buildAggregationBuilder(Collection<Selector> groupingSelectors,Integer limit,Integer internalLimit,ProjectParsed queryData){
  OrderBy orderBy=queryData.getOrderBy();
  Select select=queryData.getSelect();
  Map<String,OrderByClause> orderByMap=getOrderByClauseMap(orderBy);
  AggregationBuilder aggregationBuilder=null;
  AggregationBuilder lastAggregationBuilder=null;
  for (  Selector term : groupingSelectors) {
    String fieldName=SelectorUtils.getSelectorFieldName(term);
    if (aggregationBuilder == null) {
      lastAggregationBuilder=aggregationBuilder=AggregationBuilders.terms(fieldName).field(fieldName);
      if (limit != null) {
        ((TermsBuilder)lastAggregationBuilder).size(limit);
      }
      sortSubAggregation(fieldName,orderByMap,(TermsBuilder)lastAggregationBuilder);
    }
 else {
      lastAggregationBuilder=AggregationBuilders.terms(fieldName).field(fieldName);
      ((TermsBuilder)lastAggregationBuilder).size(internalLimit);
      sortSubAggregation(fieldName,orderByMap,(TermsBuilder)lastAggregationBuilder);
      aggregationBuilder.subAggregation(lastAggregationBuilder);
    }
  }
  if (aggregationBuilder != null) {
    addFunctionAggregation(select,orderByMap,lastAggregationBuilder);
  }
  return aggregationBuilder;
}

Fixed version (ground truth):
/** 
 * Creates the AggregationBuilder for a GroupBy or a Distinct
 */
private AggregationBuilder buildAggregationBuilder(Collection<Selector> groupingSelectors,Integer limit,Integer internalLimit,ProjectParsed queryData){
  OrderBy orderBy=queryData.getOrderBy();
  Select select=queryData.getSelect();
  Map<String,OrderByClause> orderByMap=getOrderByClauseMap(orderBy);
  AggregationBuilder aggregationBuilder=null;
  AggregationBuilder lastAggregationBuilder=null;
  for (  Selector term : groupingSelectors) {
    String fieldName=SelectorUtils.getSelectorFieldName(term);
    if (aggregationBuilder == null) {
      lastAggregationBuilder=aggregationBuilder=AggregationBuilders.terms(fieldName).field(fieldName);
      if (limit != null) {
        ((TermsBuilder)lastAggregationBuilder).size(limit);
      }
      sortSubAggregation(fieldName,orderByMap,(TermsBuilder)lastAggregationBuilder);
    }
 else {
      AggregationBuilder newAggregationBuilder=AggregationBuilders.terms(fieldName).field(fieldName);
      ((TermsBuilder)lastAggregationBuilder).size(internalLimit);
      sortSubAggregation(fieldName,orderByMap,(TermsBuilder)lastAggregationBuilder);
      lastAggregationBuilder.subAggregation(newAggregationBuilder);
      lastAggregationBuilder=newAggregationBuilder;
    }
  }
  if (aggregationBuilder != null) {
    addFunctionAggregation(select,orderByMap,lastAggregationBuilder);
  }
  return aggregationBuilder;
}