FAQ Database Discussion Community

jpa 2 CriteriaQuery do not discriminate child entities

I have an entity which have a relation of one to many with another entity. say 1A -> 1.*B i wrote this query. CriteriaBuilder cb = super.getEntityManager().getCriteriaBuilder(); CriteriaQuery<A> select = cb.createQuery(A.class); Root<A> from = select.from(A.class); Join<A, B> joinB = from.<A, B>join("b"); select.select(from); select.where( cb.between(joinB.<Date>get("date"), dateA, dateB) ); the problem: The...