标签:
hibernate分页实现
public List<Employee> pageQuery(int maxResult , int currentPage){ Session session = sf.openSession(); session.beginTransaction(); try { Query q = session.createQuery("from com.cx.hqlQuery.Employee"); q.setFirstResult((currentPage - 1)*maxResult); q.setMaxResults(maxResult); return q.list(); }catch (Exception e) { throw new RuntimeException(e); }finally { session.getTransaction().commit(); session.close(); } } @Test public void test(){ List<Employee> list = pageQuery(3,1); for (int i = 0 ; i < list.size() ; i++) { System.out.println(list.get(i).getEmpName()); } }
Hibernate对连接池(c3p0)的支持
作用管理链接;提升连接效率
标签:
原文地址:http://www.cnblogs.com/cxspace/p/5738989.html