我尝试使用JPA来计算行数。我想要使用where子句,但是我无法做到。
CriteriaBuilder qb = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> cq = qb.createQuery(Long.class);
cq.select(qb.count(cq.from(MyEntity.class)));
cq.where(); //how to write where clause
return entityManager.createQuery(cq).getSingleResult();
我该如何设置where子句,例如where age="45"。
谢谢提前。