String HQL_QUERY = "select new map(max(projectCount) as max_project_count," +
"min(employeeCount) as min_emp_count, count(*) as company_count) from Company comp";
/**
* If the above query does'nt return unique result, the
* 'uniqueResult' method throws an exception.
*
* org.hibernate.NonUniqueResultException: query did not return a unique result: 8
*
* So be sure while using this method.
*/
Map stats = (Map) session.createQuery(HQL_QUERY).uniqueResult();
System.out.println(stats);