Integer cnt = Integer.valueOf(payInfoDao.getCurrentSession().createSQLQuery("select count(*) from (select t.mechno,count(*) from (select * from boc_payinfo " + whereStr + ") t, mp_merinfo m where t.mechno = m.mechno group by t.mechno) as b ").list().get(0).toString());
你試試這樣吧。
StringBuffer sb = new StringBuffer();
sb.append("select count(*) from (select t.mechno,count(*) from (select * from boc_payinfo");
sb.append(whereStr);
sb.append(") t, mp_merinfo m where t.mechno = m.mechno group by t.mechno) as b ");
String res = payInfoDao.getCurrentSession().createSQLQuery(sb.toString()).list().get(0).toString();
Integer cnt = Integer.valueOf(res);