1 Reply Latest reply on Jan 20, 2016 9:18 AM by O O

    How to get result set size of DetachedCriteria

    Dave Chen Master

      When a DetachedCrieria has projections, how to get the row count of the DetachedCriteria result set? 

      For HQL:


      select count(*) from (select name, sum(grade) from score group by name).


      For hibernate, how to implement Subqueries.rowCount(DetachedCriteria dc)?


      If there is a way to extend a hibernate class, get sql from the DetachedCriteria, then I can add select count(*) from (sql).


      criteria.list().size() will give me the answer, but the result set may have millions of records, too expensive.


      Thanks for help.