2

我正在尝试从 spring Data JPA 中的表中获取总结果的计数,但是我如何 在查询执行期间提供的参数列表中找不到此错误 Query argument pattern not found

以下是我尝试过的:

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();

我在谷歌上找到了例子,但没有谓词。当我包含谓词时,我得到了上述异常。

4

0 回答 0