如何使用Spring的HibernateTemplate分頁

    public List getListForPage(final String hql, final int offset, 
          final int length) { 
         List list = getHibernateTemplate().executeFind(new HibernateCallback() { 
          public Object doInHibernate(Session session) 
            throws HibernateException, SQLException { 
          Query query = session.createQuery(hql); 
           query.setFirstResult(offset); 
           query.setMaxResults(length); 
           List list = query.list(); 
           return list; 
          } 
         }); 
         return list; 
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章