Program: 189410
Project: 189410
Buggy source:
@Override public SearchResult<Submission> filterSearchSubmissions(SearchFilter filter,SearchOrder orderBy,SearchDirection direction,int offset,int limit){
  int paramIndex=1;
  Map<String,Object> params=new HashMap<String,Object>();
  ANDList andList=new ANDList();
  for (  String searchText : filter.getSearchText()) {
    ORList orList=new ORList();
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),"String_Node_Str" + searchText + "String_Node_Str");
    andList.add(orList);
  }
  ORList orList=new ORList();
  for (  String stateName : filter.getStates()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),stateName);
  }
  andList.add(orList);
  orList=new ORList();
  for (  Person assignee : filter.getAssignees()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),assignee);
  }
  andList.add(orList);
  orList=new ORList();
  for (  EmbargoType embargo : filter.getEmbargoTypes()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),embargo);
  }
  andList.add(orList);
  orList=new ORList();
  for (  Semester semester : filter.getGraduationSemesters()) {
    ANDList semesterList=new ANDList();
    if (semester.year != null) {
      semesterList.add(new Statement("String_Node_Str" + paramIndex));
      params.put("String_Node_Str" + (paramIndex++),semester.year);
    }
    if (semester.month != null) {
      semesterList.add(new Statement("String_Node_Str" + paramIndex));
      params.put("String_Node_Str" + (paramIndex++),semester.month);
    }
    if (semesterList.size() > 0)     orList.add(semesterList);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String degree : filter.getDegrees()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),degree);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String department : filter.getDepartments()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),department);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String college : filter.getColleges()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),college);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String major : filter.getMajors()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),major);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String docType : filter.getDocumentTypes()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),docType);
  }
  andList.add(orList);
  if (filter.getUMIRelease() != null) {
    if (filter.getUMIRelease()) {
      andList.add(new Statement("String_Node_Str"));
    }
 else {
      andList.add(new Statement("String_Node_Str"));
    }
  }
  if (filter.getSubmissionDateRangeStart() != null && filter.getSubmissionDateRangeEnd() != null) {
    Date start=filter.getSubmissionDateRangeStart();
    Date end=filter.getSubmissionDateRangeEnd();
    andList.add(new Statement("String_Node_Str" + paramIndex));
    andList.add(new Statement("String_Node_Str" + (paramIndex + 1)));
    params.put("String_Node_Str" + (paramIndex++),start);
    params.put("String_Node_Str" + (paramIndex++),end);
  }
  StringBuilder queryText=new StringBuilder();
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  params.put("String_Node_Str",AttachmentType.PRIMARY);
  queryText.append("String_Node_Str");
  andList.buildClause(queryText);
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  String orderByClause=SUBMISSION_ORDER_BY_COLUMNS[orderBy.ordinal()];
  if (direction == SearchDirection.DESCENDING)   orderByClause=orderByClause.replaceAll("String_Node_Str","String_Node_Str");
 else   orderByClause=orderByClause.replaceAll("String_Node_Str","String_Node_Str");
  queryText.append("String_Node_Str" + orderByClause);
  if (Logger.isDebugEnabled()) {
    String message="String_Node_Str" + queryText.toString() + "String_Node_Str";
    for (    String key : params.keySet()) {
      message+="String_Node_Str" + key + "String_Node_Str"+ params.get(key)+ "String_Node_Str";
    }
    Logger.debug(message);
  }
  TypedQuery<JpaSubmissionImpl> limittedQuery=JPA.em().createQuery(queryText.toString(),JpaSubmissionImpl.class);
  limittedQuery.setFirstResult(offset);
  limittedQuery.setMaxResults(limit);
  for (  String key : params.keySet())   limittedQuery.setParameter(key,params.get(key));
  TypedQuery<JpaSubmissionImpl> fullQuery=JPA.em().createQuery(queryText.toString(),JpaSubmissionImpl.class);
  for (  String key : params.keySet())   fullQuery.setParameter(key,params.get(key));
  JpaSearchResultsImpl<Submission> result=new JpaSearchResultsImpl(filter,direction,orderBy,offset,limit,(List)limittedQuery.getResultList(),fullQuery.getResultList().size());
  return result;
}

Fixed version (ground truth):
@Override public SearchResult<Submission> filterSearchSubmissions(SearchFilter filter,SearchOrder orderBy,SearchDirection direction,int offset,int limit){
  int paramIndex=1;
  Map<String,Object> params=new HashMap<String,Object>();
  ANDList andList=new ANDList();
  for (  String searchText : filter.getSearchText()) {
    ORList orList=new ORList();
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),"String_Node_Str" + searchText + "String_Node_Str");
    andList.add(orList);
  }
  ORList orList=new ORList();
  for (  String stateName : filter.getStates()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),stateName);
  }
  andList.add(orList);
  orList=new ORList();
  for (  Person assignee : filter.getAssignees()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),assignee);
  }
  andList.add(orList);
  orList=new ORList();
  for (  EmbargoType embargo : filter.getEmbargoTypes()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),embargo);
  }
  andList.add(orList);
  orList=new ORList();
  for (  Semester semester : filter.getGraduationSemesters()) {
    ANDList semesterList=new ANDList();
    if (semester.year != null) {
      semesterList.add(new Statement("String_Node_Str" + paramIndex));
      params.put("String_Node_Str" + (paramIndex++),semester.year);
    }
    if (semester.month != null) {
      semesterList.add(new Statement("String_Node_Str" + paramIndex));
      params.put("String_Node_Str" + (paramIndex++),semester.month);
    }
    if (semesterList.size() > 0)     orList.add(semesterList);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String degree : filter.getDegrees()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),degree);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String department : filter.getDepartments()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),department);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String college : filter.getColleges()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),college);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String major : filter.getMajors()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),major);
  }
  andList.add(orList);
  orList=new ORList();
  for (  String docType : filter.getDocumentTypes()) {
    orList.add(new Statement("String_Node_Str" + paramIndex));
    params.put("String_Node_Str" + (paramIndex++),docType);
  }
  andList.add(orList);
  if (filter.getUMIRelease() != null) {
    if (filter.getUMIRelease()) {
      andList.add(new Statement("String_Node_Str"));
    }
 else {
      andList.add(new Statement("String_Node_Str"));
    }
  }
  if (filter.getSubmissionDateRangeStart() != null && filter.getSubmissionDateRangeEnd() != null) {
    Date start=filter.getSubmissionDateRangeStart();
    Date end=filter.getSubmissionDateRangeEnd();
    andList.add(new Statement("String_Node_Str" + paramIndex));
    andList.add(new Statement("String_Node_Str" + (paramIndex + 1)));
    params.put("String_Node_Str" + (paramIndex++),start);
    params.put("String_Node_Str" + (paramIndex++),end);
  }
  StringBuilder queryText=new StringBuilder();
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  queryText.append("String_Node_Str");
  params.put("String_Node_Str",AttachmentType.PRIMARY);
  if (andList.size() > 0) {
    queryText.append("String_Node_Str");
    andList.buildClause(queryText);
    queryText.append("String_Node_Str");
  }
  queryText.append("String_Node_Str");
  String orderByClause=SUBMISSION_ORDER_BY_COLUMNS[orderBy.ordinal()];
  if (direction == SearchDirection.DESCENDING)   orderByClause=orderByClause.replaceAll("String_Node_Str","String_Node_Str");
 else   orderByClause=orderByClause.replaceAll("String_Node_Str","String_Node_Str");
  queryText.append("String_Node_Str" + orderByClause);
  if (Logger.isDebugEnabled()) {
    String message="String_Node_Str" + queryText.toString() + "String_Node_Str";
    for (    String key : params.keySet()) {
      message+="String_Node_Str" + key + "String_Node_Str"+ params.get(key)+ "String_Node_Str";
    }
    Logger.debug(message);
  }
  TypedQuery<JpaSubmissionImpl> limittedQuery=JPA.em().createQuery(queryText.toString(),JpaSubmissionImpl.class);
  limittedQuery.setFirstResult(offset);
  limittedQuery.setMaxResults(limit);
  for (  String key : params.keySet())   limittedQuery.setParameter(key,params.get(key));
  TypedQuery<JpaSubmissionImpl> fullQuery=JPA.em().createQuery(queryText.toString(),JpaSubmissionImpl.class);
  for (  String key : params.keySet())   fullQuery.setParameter(key,params.get(key));
  JpaSearchResultsImpl<Submission> result=new JpaSearchResultsImpl(filter,direction,orderBy,offset,limit,(List)limittedQuery.getResultList(),fullQuery.getResultList().size());
  return result;
}