criteriabuilder predicate version

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

criteriabuilder predicate version

Matthew Broadhead-2
is it not possible to query the @Version field using criteriabuilder?

i am trying this and it is not returning any results
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Document> cq = cb.createQuery(Document.class);
Root<Document> document = cq.from(Document.class);
List<Predicate> predicateList = new ArrayList<>();
predicateList.add(cb.isNull(document.get("version")));
cq.select(document);
cq.where(cb.and(predicateList.toArray(new
Predicate[predicateList.size()])));
cq.distinct(true);
cq.orderBy(cb.desc(document.get("id")));
TypedQuery<Document> query = em.createQuery(cq);
query.setMaxResults(250);
List<Document> list = query.getResultList();
return list;

if i switch to another Long field which supports null then it works fine