how to get the total results count in pagination

714 views Asked by At

I'm trying to get the count of total results from table in spring Data JPA but some how I am getting this error Query argument pattern not found in the list of parameters provided during query execution.

below is what I tried:

CriteriaQuery<Long> countQuery = criteriaBuilder
  .createQuery(Long.class);
countQuery.select(criteriaBuilder
  .count(countQuery.from(Foo.class))).where(criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()])));

Long count = entityManager.createQuery(countQuery)
  .getSingleResult();

I found examples on google but with out predicates. when I include predicate I got the above exception.

0

There are 0 answers