You can use a counter if there is only one group per column.
HQL:
select count(distinct name) as myCount from user
Criteria:
DetachedCriteria.ForClass(typeof(UserDTO))
.setProjections(Projections.ProjectionList()
.Add(Projections.countDistinct("name"),"myCount"));
source
share