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;
}
});

上一篇:Java之集合(十三)WeakHashMap


下一篇:Dynamics CRM2013 从外部系统取到CRM系统的用户头像