Created
April 16, 2018 12:42
-
-
Save ThangLeQuoc/e22f9dd02ac576ec7ca244b8d80a2de6 to your computer and use it in GitHub Desktop.
Count number of result from result list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
CriteriaBuilder qb = entityManager.getCriteriaBuilder(); | |
CriteriaQuery<Long> cq = qb.createQuery(Long.class); | |
cq.select(qb.count(cq.from(MyEntity.class))); | |
cq.where(/*your stuff*/); | |
return entityManager.createQuery(cq).getSingleResult(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment