hibernate分页方法之一 -------->回调函数法,与Spring结合
public List<Users> getUsers(final int start, final int i) {
// TODO Auto-generated method stub
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException,
SQLException {
final String hql = "FROM Users u ORDER BY u.userid DESC";
Query query = s.createQuery(hql);
query.setFirstResult(start);
query.setMaxResults(i);
List<Users> list = query.list();
return list;
}
});
}