Program: 112329
Project: 112329
Buggy source:
private Set<Long> addPredicateString(Set<Long> thePids,List<IQueryParameterType> theOrParams){
  if (theOrParams == null || theOrParams.isEmpty()) {
    return thePids;
  }
  CriteriaBuilder builder=myEntityManager.getCriteriaBuilder();
  CriteriaQuery<Long> cq=builder.createQuery(Long.class);
  Root<ResourceIndexedSearchParamString> from=cq.from(ResourceIndexedSearchParamString.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  List<Predicate> codePredicates=new ArrayList<Predicate>();
  for (  IQueryParameterType nextOr : theOrParams) {
    IQueryParameterType params=nextOr;
    String string;
    if (params instanceof IPrimitiveDatatype<?>) {
      IPrimitiveDatatype<?> id=(IPrimitiveDatatype<?>)params;
      string=id.getValueAsString();
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + params.getClass());
    }
    Predicate singleCode=builder.equal(from.get("String_Node_Str"),normalizeString(string));
    if (params instanceof StringParam && ((StringParam)params).isExact()) {
      Predicate exactCode=builder.equal(from.get("String_Node_Str"),string);
      singleCode=builder.and(singleCode,exactCode);
    }
    codePredicates.add(singleCode);
  }
  Predicate masterCodePredicate=builder.or(codePredicates.toArray(new Predicate[0]));
  Predicate type=builder.equal(from.get("String_Node_Str"),myResourceName);
  if (thePids.size() > 0) {
    Predicate inPids=(from.get("String_Node_Str").in(thePids));
    cq.where(builder.and(type,inPids,masterCodePredicate));
  }
 else {
    cq.where(builder.and(type,masterCodePredicate));
  }
  TypedQuery<Long> q=myEntityManager.createQuery(cq);
  return new HashSet<Long>(q.getResultList());
}

Fixed version (ground truth):
private Set<Long> addPredicateString(String theParamName,Set<Long> thePids,List<IQueryParameterType> theOrParams){
  if (theOrParams == null || theOrParams.isEmpty()) {
    return thePids;
  }
  CriteriaBuilder builder=myEntityManager.getCriteriaBuilder();
  CriteriaQuery<Long> cq=builder.createQuery(Long.class);
  Root<ResourceIndexedSearchParamString> from=cq.from(ResourceIndexedSearchParamString.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  List<Predicate> codePredicates=new ArrayList<Predicate>();
  for (  IQueryParameterType nextOr : theOrParams) {
    IQueryParameterType params=nextOr;
    String string;
    if (params instanceof IPrimitiveDatatype<?>) {
      IPrimitiveDatatype<?> id=(IPrimitiveDatatype<?>)params;
      string=id.getValueAsString();
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + params.getClass());
    }
    Predicate singleCode=builder.equal(from.get("String_Node_Str"),normalizeString(string));
    if (params instanceof StringParam && ((StringParam)params).isExact()) {
      Predicate exactCode=builder.equal(from.get("String_Node_Str"),string);
      singleCode=builder.and(singleCode,exactCode);
    }
    codePredicates.add(singleCode);
  }
  Predicate masterCodePredicate=builder.or(codePredicates.toArray(new Predicate[0]));
  Predicate type=builder.equal(from.get("String_Node_Str"),myResourceName);
  Predicate name=builder.equal(from.get("String_Node_Str"),theParamName);
  if (thePids.size() > 0) {
    Predicate inPids=(from.get("String_Node_Str").in(thePids));
    cq.where(builder.and(type,name,masterCodePredicate,inPids));
  }
 else {
    cq.where(builder.and(type,name,masterCodePredicate));
  }
  TypedQuery<Long> q=myEntityManager.createQuery(cq);
  return new HashSet<Long>(q.getResultList());
}