@Test public void test9(){ //根据部门编号进行分组,再根据每个部门总工资>5000 Session ss=HibernateUtil.getSession(); String hql="from Emp"; //实现分页需要当前页面currentPageIndex int currentPageIndex=2; //每页显示的个数pageSize=5 int pageSize=5; Query qr=ss.createQuery(hql); //方法里面出入开始记录数(currentPageIndex-1)*pageSize qr.setFirstResult((currentPageIndex-1)*pageSize); qr.setMaxResults(pageSize); List<Emp> el =qr.list(); System.out.println(el.size()); for (Emp emp : el) { System.out.println(emp); } HibernateUtil.closeResource(ss); }