Criteria crit = getUsersCriteria(groupId); crit.setProjection(Projections.rowCount()); List results = crit.list(); if (results.size() > 1) { throw new RuntimeException("Querying for user count returned multiple results!"); } Integer count = (Integer) results.get(0); return count.intValue();
return getBeansInGroupCount(User.class, groupId);
    public int getUsersInGroupCount(Integer groupId) {                Criteria crit = getUsersCriteria(groupId);        crit.setProjection(Projections.rowCount());        List results = crit.list();        if (results.size() > 1) {            throw new RuntimeException("Querying for user count returned multiple results!");        }        Integer count = (Integer) results.get(0);        return count.intValue();    }