s1是什么东西?hsql的也支持普通的sql的呀,直接select count(*)就好了的
解决方案 »
- 怎样在使用activemq发消息的时候采用udp的传输方式,而不是默认的tcp?
- Myeclipse安装的时候出错,郁闷~
- linux下关闭tomcat服务,却无法停掉tomcat启动时应用的jdk进程
- 在spring中做sqlserver2000的连接问题 急待解决 高分送于解惑者
- java通过itext操作PDF文件的问题
- [求助]请问Web Service是什么?和J2EE,EJB是啥关系??谢谢!!!
- tomcat5的配置问题!!在线等待!!!!
- 大讨论,java在全国那些地方发展的好!!
- 请教各位,在struts中可以一个jsp页面提交多个action吗,怎么配置阿?一个jsp页面中可以有多个actionform吗?
- ArrayList里面能不能add一个ArrayList对象?
- 运行个struts标签的页面竟然这样???
- validator使用问题
就是分页的时候希望能先取到表中的记录总数,最好是不用select count(*),不知有没有一个取得总记录数的方法,看了API,好象也没找到。
return ((Integer)session.createQuery(hsql).iterate().next()).intValue();
这里 id 是主键,当然,要根据你的实际情况写这个字段的名称。
* <p>
* 对数据库进行操作,返回员工总人数 为分页提供服务
*
* @return intcount
*
*/ public int count() throws Exception {
log.warn("---->显示员工总人数");
int counts;
Session session = BaseHibernate.getSession();
Integer count = (Integer) session.createQuery(
"select count(*) from User s").uniqueResult();
counts = count.intValue();
BaseHibernate.closeSession(session);
return counts;
}