Program: 112332
Project: 112332
Buggy source:
private Set<Long> addPredicateDate(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<ResourceIndexedSearchParamDate> from=cq.from(ResourceIndexedSearchParamDate.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  List<Predicate> codePredicates=new ArrayList<Predicate>();
  for (  IQueryParameterType nextOr : theOrParams) {
    IQueryParameterType params=nextOr;
    if (params instanceof QualifiedDateParam) {
      QualifiedDateParam id=(QualifiedDateParam)params;
      DateRangeParam range=new DateRangeParam(id);
      addPredicateDateFromRange(builder,from,codePredicates,range);
    }
 else     if (params instanceof DateRangeParam) {
      DateRangeParam range=(DateRangeParam)params;
      addPredicateDateFromRange(builder,from,codePredicates,range);
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + params.getClass());
    }
  }
  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> addPredicateDate(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<ResourceIndexedSearchParamDate> from=cq.from(ResourceIndexedSearchParamDate.class);
  cq.select(from.get("String_Node_Str").as(Long.class));
  List<Predicate> codePredicates=new ArrayList<Predicate>();
  for (  IQueryParameterType nextOr : theOrParams) {
    IQueryParameterType params=nextOr;
    if (params instanceof QualifiedDateParam) {
      QualifiedDateParam id=(QualifiedDateParam)params;
      DateRangeParam range=new DateRangeParam(id);
      addPredicateDateFromRange(builder,from,codePredicates,range);
    }
 else     if (params instanceof DateRangeParam) {
      DateRangeParam range=(DateRangeParam)params;
      addPredicateDateFromRange(builder,from,codePredicates,range);
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + params.getClass());
    }
  }
  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());
}