我想这样做,但要使用标准API:
select count(distinct e) from Event e, IN(e.userAccessPermissions) p where p.principal = :principal and p.permission in (:permissions)
有任何想法吗?
您可以在CriteriaBuilder上使用countDistinct
criteriaQuery.select(criteriaBuilder.countDistinct(entityRoot))