Suppose I have a table Person and i want to count all those people whose \"birthDate\" is not null and they are a student. Assuming i have two columns :
birthDat
Criteria crit = session.createCriteria(Person.class);
crit.setProjection(Projections.rowCount());
crit.add( Restrictions.isNotNull("birthDate"));
crit.add( Restrictions.eq("isStudent", true));
return (Long) crit.uniqueResult();
The (Long)crit.uniqueResult() will cause NonUniqueResultException. I check the crit.list(). It is an ArrayList having 2 items. The first item of the arraylist contains the count. The second item always contains a 0. Is it the expected result of rowCount?
Thanks