package dao.impl; import java.util.List; import org.hibernate.Query; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import dao.PersonDao; import util.PageBean; public class PersonDaoImpl extends HibernateDaoSupport implements PersonDao { public void findByPage(PageBean pageBean) { // 1、查询总记录数 String hql = "SELECT COUNT(*) FROM Person"; Query query = super.getSession().createQuery(hql); Long count = (Long) query.uniqueResult(); int value = count.intValue(); pageBean.setTotalRecord(value); // 2、查询显示数据集合 hql = "FROM Person"; query = super.getSession().createQuery(hql); query.setFirstResult(pageBean.getStart()); query.setMaxResults(pageBean.getPageSize()); pageBean.setList(query.list()); } }