- //查新记录,创建Query
- Query query= userDao.createQuery(" from User where userId like ? and userEname like ? and userCname like ? ", "%"+userId+"%","%"+userEname+"%","%"+userCname+"%");
- //查新总记录数,创建Query
- Query query1= userDao.createQuery(" from User where userId like ? and userEname like ? and userCname like ? ", "%"+userId+"%","%"+userEname+"%","%"+userCname+"%");
- //获取list的时候加上这是开始数据跟 结束数据 int 类型
- List<User> result = query.setFirstResult(min).setMaxResults(max).list();
- //如果是一条Query的话query.list()的记录是分页的数据,不能拿到总数,所以从新创建一个Query 进行不加设置页数的list()
- List<User> resultTotal = query1.list();
- //将分页结果放到ov中,进行传输
- page.setResult(result);
- //将总数放到ov中,进行传输
- page.setTotalCount(resultTotal.size());
- return page;