I'm writing an application where users can formulate their queries on datasets (=entities) graphically, allowing them to hide columns, specify constraints and operators on them. The results are then shown in pages.
In order to be able to display something like 'Page X of Y' I need the total count of rows the query would return if it was not paginated.
This is easy for a plain query with arbitrary constraints, but not possible when one of the result set columns is a count, grouped by another column, like in this example the count of employees per department:
Code:
count | department
-----------+----------------
13 | Sales
45 | Development
2 | Logistics
Ideally I would like to be able to execute a count on the (then) nested HQL or, at least, be able to obtain the generated SQL and do the count myself.
Any insights are appreciated
G.