Hibernate分页-count总记录数的计算
来源:互联网 发布:js使input失去焦点 编辑:程序博客网 时间:2024/04/29 05:07
**EmpDAO**// select count(id) from Emp where...order by... 只有一条结果 public Long getCountEmps(String hql, Map<String, Object> emp) { return (Long) HibernateSessionFactory.getSession() .createQuery("select count(id) from Emp").setProperties(emp) .uniqueResult();**EmpBiz**EmpDAO dao = new EmpDAO(); public List<Emp> findByPage() { Transaction tx = null; List<Emp> result = null; try { tx = HibernateSessionFactory.getSession().beginTransaction(); int count = dao.getCountEmps(null, null).intValue();// 统计结果封装是长整数Long,这个用来取整数值 System.out.println("总共" + count + "条记录"); // (count+size-1)/size // count % size ==0 ? (count/size):(count/size+1) 分页算法 tx.commit(); } catch (HibernateException e) { // TODO Auto-generated catch block e.printStackTrace(); if (tx != null) { tx.rollback(); } } return result; }**T1**EmpBiz biz = new EmpBiz(); @Test public void test() { List<Emp> result = biz.findByPage(); for (Emp emp : result) { System.out.println(emp.getEname()); } }
1 0
- Hibernate分页-count总记录数的计算
- hibernate 分页查询求总记录数遇到的问题
- hibernate 多表联合查询,分页,重复记录导致的总记录数不对的解决方法。
- Hibernate DetachedCriteria方式分页查询返回总记录数
- hibernate查询总记录数
- Hibernate通过Cirteria求翻页插件的总记录数
- 分页的总页数计算
- HBase计算表的总count
- 使用Hibernate criteria进行分页查询时,如何实现一次查询取得总记录数和分页后结果集
- 用ObjectDataSource作数据源,用GridView分页时,获取总记录数的方法
- 用ObjectDataSource作数据源,用GridView分页时,获取总记录数的方法
- mysql 分组查询数据时,如何获得用于分页的总记录数?
- MySQL中获取当前查询的总记录数,适用于分页等应用
- mysql 分组查询数据时,如何获得用于分页的总记录数?
- 资料 mybatis 一条语句 分页查询(同时获得符合条件的总记录数)
- 分页时高效的总页数计算
- 分页时高效的总页数计算
- DataGrid终极分页法:给分页加上总记录数、总页数、当前页数
- hdu1160-最长上升子序列
- 动态实现顺序表
- C++模板类继承中的Name Lookup
- 刷刷笔试题~~[字符串类编程]
- C# 调用 C++ 在Release下重新生成的问题
- Hibernate分页-count总记录数的计算
- libzdb
- SpringBoot操作MongoDB实现分页查询
- libzdb简介
- Codeforces Round #354 (Div. 2) D. Theseus and labyrinth(BFS)
- 题目:将一个随机的整数转换成一个按各位上数值大小排序的整数
- kbengine引擎的安装
- NBOJv2——Problem 1037: Wormhole(map邻接表+优先队列SPFA)
- 数据库连接池libzdb的使用