I try to create request:
Criteria criteria = session.createCriteia(User.class);
criteria.setFetchMode(field, FetchMode.JOIN);
int count1 = criteria.list().size(); //340
Number count2 = (Number) criteria.setProjection(Projections.rowCount()).uniqueResult(); //279
How to return 340
without calling criteria.list().size()
?
I think while using
Projections.rowCount()
hibernate ignorescriteria.setFetchMode(field, FetchMode.JOIN);
You can use
createAlias
criteria.createAlias("field","field", JoinType.LEFT_OUTER_JOIN);
Check query generated by hibernate in both the cases by using
hibernate.show_sql
in Hibernate configuration filehttps://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html#configuration-optional