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.add( Restrictions.isNotNull("birthDate")); crit.add( Restrictions.eq("isStudent", true)); crit.setProjection(Projections.rowCount()); Integer count = (Integer)crit.uniqueResult();