docs: public static <T> CriteriaQuery<Long> countCriteria(EntityManager em, CriteriaQuery<T> criteria) {
          CriteriaBuilder builder = em.getCriteriaBuilder();
          CriteriaQuery<Long> countCriteria = builder.createQuery(Long.class);
          copyCriteriaNoSelection(criteria, countCriteria);
          countCriteria.select(builder.count(findRoot(countCriteria, criteria.getResultType())));
  
          return countCriteria;
      }