hibernate取出count(*)的办法

1、定义查询语句
    String sql="select count(*) from ExcelInfor";
2、获取count(*)返回结果:
 (1)int count=Integer.parseInt(session.createSQLQuery(sql).list().get(0).toString());
 (2)int count=((Long)(session.createQuery(sql).iterate().next())).intValue();
 (3)int count=((Integer)(session.createQuery(sql).uniqueResult()).intValue();

posted @ 2016-03-10 09:07  追风的岁月无惧风雨  阅读(1574)  评论(0)    收藏  举报