Program: 169019
Project: 169019
Buggy source:
private PagedList<T> getResultListViaObjectQuery(long totalSize){
  String queryString=getQueryString0();
  Class<?> expectedResultType;
  if (keysetExtraction) {
    expectedResultType=Object[].class;
  }
 else {
    expectedResultType=selectManager.getExpectedQueryResultType();
  }
  TypedQuery<T> query=(TypedQuery<T>)em.createQuery(queryString,expectedResultType).setMaxResults(pageSize);
  if (keysetMode == KeysetMode.NONE) {
    query.setFirstResult(firstRow);
  }
  KeysetExtractionObjectBuilder<T> objectBuilder=null;
  ObjectBuilder<T> transformerObjectBuilder=selectManager.getSelectObjectBuilder();
  if (keysetExtraction) {
    int keysetSize=orderByManager.getOrderByCount();
    if (transformerObjectBuilder == null) {
      objectBuilder=new KeysetExtractionObjectBuilder<T>(keysetSize);
    }
 else {
      objectBuilder=new DelegatingKeysetExtractionObjectBuilder<T>(transformerObjectBuilder,keysetSize);
    }
    transformerObjectBuilder=objectBuilder;
  }
  if (transformerObjectBuilder != null) {
    for (    QueryTransformer transformer : cbf.getQueryTransformers()) {
      transformer.transformQuery((TypedQuery<T>)query,transformerObjectBuilder);
    }
  }
  parameterizeQuery(query);
  List<T> result=query.getResultList();
  if (result.isEmpty()) {
    KeysetPage newKeysetPage=null;
    if (keysetMode == KeysetMode.NEXT) {
      newKeysetPage=keysetPage;
    }
    return new PagedListImpl<T>(newKeysetPage,totalSize,firstResult,pageSize);
  }
  KeysetPage newKeyset=null;
  if (keysetExtraction) {
    Serializable[] lowest=objectBuilder.getLowest();
    Serializable[] highest=objectBuilder.getHighest();
    newKeyset=new KeysetPageImpl(firstRow,pageSize,lowest,highest);
  }
  PagedList<T> pagedResultList=new PagedListImpl<T>(result,newKeyset,totalSize,firstResult,pageSize);
  return pagedResultList;
}

Fixed version (ground truth):
private PagedList<T> getResultListViaObjectQuery(long totalSize){
  String queryString=getQueryString0();
  Class<?> expectedResultType;
  if (keysetExtraction) {
    expectedResultType=Object[].class;
  }
 else {
    expectedResultType=selectManager.getExpectedQueryResultType();
  }
  TypedQuery<T> query=(TypedQuery<T>)em.createQuery(queryString,expectedResultType).setMaxResults(pageSize);
  if (keysetMode == KeysetMode.NONE) {
    query.setFirstResult(firstRow);
  }
  KeysetExtractionObjectBuilder<T> objectBuilder=null;
  ObjectBuilder<T> transformerObjectBuilder=selectManager.getSelectObjectBuilder();
  if (keysetExtraction) {
    int keysetSize=orderByManager.getOrderByCount();
    if (transformerObjectBuilder == null) {
      objectBuilder=new KeysetExtractionObjectBuilder<T>(keysetSize);
    }
 else {
      objectBuilder=new DelegatingKeysetExtractionObjectBuilder<T>(transformerObjectBuilder,keysetSize);
    }
    transformerObjectBuilder=objectBuilder;
  }
  if (transformerObjectBuilder != null) {
    for (    QueryTransformer transformer : cbf.getQueryTransformers()) {
      query=transformer.transformQuery((TypedQuery<T>)query,transformerObjectBuilder);
    }
  }
  parameterizeQuery(query);
  List<T> result=query.getResultList();
  if (result.isEmpty()) {
    KeysetPage newKeysetPage=null;
    if (keysetMode == KeysetMode.NEXT) {
      newKeysetPage=keysetPage;
    }
    return new PagedListImpl<T>(newKeysetPage,totalSize,firstResult,pageSize);
  }
  KeysetPage newKeyset=null;
  if (keysetExtraction) {
    Serializable[] lowest=objectBuilder.getLowest();
    Serializable[] highest=objectBuilder.getHighest();
    newKeyset=new KeysetPageImpl(firstRow,pageSize,lowest,highest);
  }
  PagedList<T> pagedResultList=new PagedListImpl<T>(result,newKeyset,totalSize,firstResult,pageSize);
  return pagedResultList;
}