我想获取返回的行数而不是表中的所有结果。如何计算Hibernate查询语言中的行数?
我看到这个可以这样做:
((Integer) session.createQuery("select count(*) from ....").iterate().next()).intValue()
但是,试图将存储在一个整数格式(它说不能从Query to Integer
转换)这个查询
当我使用的是动态查询其中的值会提到下面的查询这样
theQuery = "select count(*) from THM as thm " +
"join thm.TMC as tmc " +
"join tmc.TIMCC as timcc " +
"where thm.Qid = :Qid and thm.Cv = :Cv and timcc.Did = :Did and timcc.Cv= :Cv";
Query query = session.createQuery(theQuery);
query.setInteger("Qid", Integer.parseInt(Qid));
query.setInteger("Did", Did);
query.setInteger("Cv",cV);
现在,我怎样才能通过在VA使用Hibernate查询返回的所有行数riable没有使用list.size
但直接从查询?
query.uniqueResult(); ()。next()).intValue() – user1002782 2012-01-05 13:21:54
如果我的查询不是Select count(*),而是像“from THM”开始的那样, – Jerry 2017-05-10 06:44:09