public Long count ( Criteria < T , T > criteria ) { SingularAttribute < ? super T , PK > id = getEntityManager ( ) . getMetamodel ( ) . entity ( entityClass ) . getId ( entityKey ) ; return criteria . select ( Long . class , countDistinct ( id ) ) . getSingleResult ( ) ; }
Count using a pre populated criteria