HibernateRequest { public int count() { Number result = HibernateSessionFactory.doInTransaction(new IRequest<Number>() { @Override public Number doInTransaction(Session session) { return (Number) count(createCriteria(session)); } }); return result == null ? 0 : result.intValue(); } private  HibernateRequest(Class<?> persistentClass); static HibernateRequest<T> create(Class<?> clazz); HibernateRequest<T> idEq(Object value); HibernateRequest<T> eqOrIsNull(String propertyName, Object value); HibernateRequest<T> eq(String propertyName, Object value); HibernateRequest<T> ne(String propertyName, Object value); HibernateRequest<T> ge(String propertyName, Object value); HibernateRequest<T> gt(String propertyName, Object value); HibernateRequest<T> lt(String propertyName, Object value); HibernateRequest<T> le(String propertyName, Object value); HibernateRequest<T> isNull(String propertyName); HibernateRequest<T> isNotNull(String propertyName); HibernateRequest<T> in(String propertyName, Collection<?> values); HibernateRequest<T> in(String propertyName, U... values); HibernateRequest<T> add(Criterion criterion); HibernateRequest<T> add(IBuilder... builders); HibernateRequest<T> proj(String propertyName); HibernateRequest<T> proj(String propertyName, String alias); HibernateRequest<T> projId(String pidProperty); HibernateRequest<T> projMin(String minProperty); HibernateRequest<T> projMax(String maxProperty); HibernateRequest<T> proj(Projection projection); HibernateRequest<T> distinct(); HibernateRequest<T> innerJoin(String associationPath); HibernateRequest<T> innerJoin(String associationPath, String alias); HibernateRequest<T> innerJoin(String associationPath, String alias,
            Criterion withClause); HibernateRequest<T> leftJoin(String associationPath); HibernateRequest<T> leftJoin(String associationPath, String alias); HibernateRequest<T> leftJoin(String associationPath, String alias,
            Criterion withClause); HibernateRequest<T> rightJoin(String associationPath); HibernateRequest<T> rightJoin(String associationPath, String alias); HibernateRequest<T> rightJoin(String associationPath, String alias,
            Criterion withClause); HibernateRequest<T> transform(Class<?> clazz); HibernateRequest<T> distinctToRootEntity(); HibernateRequest<T> useTransformer(ResultTransformer transformer); HibernateRequest<T> pagination(Pagination pagination); HibernateRequest<T> maxResults(int maxResults); HibernateRequest<T> orderAsc(String propertyName); HibernateRequest<T> orderDesc(String propertyName); HibernateRequest<T> fetchJoin(String... associationPaths); T first(T defaultValue); T first(); @SuppressWarnings("unchecked") List<T> list(); int count();  }
@Test public void count() { H.saveOrUpdateAll(rootsAB()); int count = H.request(Root.class).count(); assertThat(count).isEqualTo(2); }