Program: 189411
Project: 189411
Buggy source:
@Override public SearchResult<ActionLog> filterSearchActionLogs(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();
  ORList orList=new ORList();
  for (  String searchText : filter.getSearchText()) {
    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=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=ACTION_LOG_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<JpaActionLogImpl> limittedQuery=JPA.em().createQuery(queryText.toString(),JpaActionLogImpl.class);
  limittedQuery.setFirstResult(offset);
  limittedQuery.setMaxResults(limit);
  for (  String key : params.keySet())   limittedQuery.setParameter(key,params.get(key));
  TypedQuery<JpaActionLogImpl> query=JPA.em().createQuery(queryText.toString(),JpaActionLogImpl.class);
  for (  String key : params.keySet())   query.setParameter(key,params.get(key));
  JpaSearchResultsImpl<ActionLog> result=new JpaSearchResultsImpl(filter,direction,orderBy,offset,limit,(List)limittedQuery.getResultList(),query.getResultList().size());
  return result;
}

Fixed version (ground truth):
@Override public SearchResult<ActionLog> filterSearchActionLogs(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();
  ORList orList=new ORList();
  for (  String searchText : filter.getSearchText()) {
    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=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=ACTION_LOG_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<JpaActionLogImpl> limittedQuery=JPA.em().createQuery(queryText.toString(),JpaActionLogImpl.class);
  limittedQuery.setFirstResult(offset);
  limittedQuery.setMaxResults(limit);
  for (  String key : params.keySet())   limittedQuery.setParameter(key,params.get(key));
  TypedQuery<JpaActionLogImpl> query=JPA.em().createQuery(queryText.toString(),JpaActionLogImpl.class);
  for (  String key : params.keySet())   query.setParameter(key,params.get(key));
  JpaSearchResultsImpl<ActionLog> result=new JpaSearchResultsImpl(filter,direction,orderBy,offset,limit,(List)limittedQuery.getResultList(),query.getResultList().size());
  return result;
}