1. HQL分页:
Session session = HibernateUtil.getInstance().getSession();
Query query = session.createQuery("hql");
query.setFirstResult(int start); // 起始行
query.setMaxResults(int counts); // 每页行数
List list = query.list();
2. Criteria分页:
Criteria criteria = session.createCriteria(<ClassName>.class);
criteria.setFirstResult(int start);
criteria.setMaxResults(int counts);
List list = criteria.list();
时间: 2024-10-10 15:52:08