hibernate实现翻页

final DetachedCriteria detachedCrit = DetachedCriteria
    .forClass(Query.class);
  List<Query> list = getHibernateTemplate().execute(
    new HibernateCallback() {
     public List doInHibernate(Session session)
       throws HibernateException {
      Criteria criteria = detachedCrit
        .getExecutableCriteria(session);
      List items = criteria.setFirstResult(startIndex)
        .setMaxResults(pageSize).list();
      return items;
     }
    });

你可能感兴趣的:(Hibernate)