Predicate p2 = cb.equal(d.get(Dependent_.id).get(DependentId_.empid), sq);
Predicate p3 = cb.greaterThan(d.get(Dependent_.id).get(DependentId_.effDate), minDate);
Predicate p4 = cb.lessThan(d.get(Dependent_.id).get(DependentId_.effDate), maxDate);
q.where(cb.and(cb.and(cb.and(p1, p2), p3), p4));
assertEquivalence(new QueryDecorator() {
public void decorate(Query q) {
q.setParameter("empid", 101L);
q.setParameter("minDate", new Date(100));
q.setParameter("maxDate", new Date(100000));
}