Hi,emmanuel:
well,maybe I did not explain the question clearly. :)
The situation is :
I have a following HQL:
Code:
select t.f as tf, count(t.f) as tfCnt from Tbl as t where t.name like 'J%' group by t.f
I want get the record count of this hql.
How can I get it?
1.One approach is that:
Code:
Query query = session.createQuery(hql);
List list = query.list();
int recordCount = list.size();
but this appraoch is impossible if the record count exceeds more than 100000 or even large.
2.another appraoch is that:
Code:
String hql2 = "select count(*) as recordCnt from (select t.f as tf, count(t.f) as tfCnt from Tbl as t where t.name like 'J%' group by t.f) as Tmpt";
//wrap the "select count(*) from (...) as TempT" around the original hql
Query query = session.createQuery(hql2);
//Run error because Hibernate does not support hql in such syntax.
List list = query.list();
int recordCount = list.size();
I prefer to this appraoch ,but failed because of the syntax of hql.
How can I? I was deeply puzzled.
Thanks a lot!