用hibernate做count(*)查询,结果集需用createSQLQuery()
<span style="white-space:pre"> </span>String sql="SELECT COUNT(1) "
+ " from Test_Classinfo a,Test_Student b,TestStudent_Question c "
+ " where a.testId=b.testId "
+ " and b.id=c.testStudentId "
+ " and c.userAnswer!=NULL "
+ " and a.classInfoId='"+classinfoId+"'"
+ " and a.testId='"+testId+"'";
Query query = this.getCurrentSession().createSQLQuery(sql);
int count=((Number)query.uniqueResult()).intValue();
return count;