Hibeernate中的两种分页方式

1.
return getHibernateTemplate().executeFind(new HibernateCallback() {
			public Object doInHibernate(Session s) throws HibernateException {
				Criteria c = s.createCriteria(AskOnline.class);
				c.add(Restrictions.eq("boardid", new Long(bid)));			
				
				c.setFirstResult(spage);
				c.setMaxResults(perPageNum);
				return c.list();
			}
		});

2.
		final String hql ="from AskOnline a where a.boardid=? and a.isreply = 0 order by a.id desc";
		return getHibernateTemplate().executeFind(new HibernateCallback() {
			public Object doInHibernate(Session s) throws HibernateException, SQLException {
				Query query = s.createQuery(hql);
				query.setLong(0, bid);
				query.setFirstResult(spage);
				query.setMaxResults(perPageNum);
				List list = query.list();
				return list;
			}
		});

原文地址:https://www.cnblogs.com/mfrbuaa/p/4294252.html