This not work for below versions of hibernate tools.
I tired something like this:
Code:
//dc is a DetachedCriteria with my criteria.
Criteria crit = dc.getExecutableCriteria(getSession())
.setProjection(Projections.rowCount());
p.setTotalResults((Integer)crit.uniqueResult());
log.info("new total result:" +p.getTotalResults());
crit.setProjection(null);
crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
crit
.setFirstResult(p.getFirstResult())
.setMaxResults(pageSize)
.addOrder(Property.forName("startDate").desc());
p.setResults(crit.list());
I got right TotalResult but result list is lower then pageSize.
How can I solve this in below version of hibernate?
Code:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.3.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>