If you want to count the number of groups, you would need a query like this:
select count(distinct u.first_name, u.last_name, u.age)
from users u
Now this can be done with Hibernate directly as well, but the support for tuple count distinct is not emulated yet. If you want support for that for e.g. SQL Server you’d need to use the COUNT_TUPLE
function provided by Blaze-Persistence
In JPQL/HQL the use of the function would look like FUNCTION('COUNT_TUPLE', 'DISTINCT', u.firstName, u.lastName, u.age)
. You can use the JPA Criteria API for that purpose as well if you like, but I don’t think you can formulate this expression with the Hibernate Criteria API.
PostgreSQL is one of the few databases that supports this out of the box, so you wouldn’t need Blaze-Persistence for that purpose.