hql 不支持 limit, 替代方法

public List<User> getUserById(final int userId,final int maxCount,final int firstResult) throws Exception {
  final String hql = "from User where userId=? ";
  return this.getHibernateTemplate().executeFind(new HibernateCallback() {
   public Object doInHibernate(final Session session) throws HibernateException, SQLException {
    final Query query = session.createQuery(hql);
    query.setParameter(0, userId);
    query.setMaxResults(maxCount);
    query.setFirstResult(firstResult);    
    return query.list();
   }
  });
 }

原文地址:https://www.cnblogs.com/kevinge/p/2893411.html