hibernate 實現分頁

 /**
  * 分頁查詢數據
  */
 public List getfind(final int start, final int maxCount, final String hql) {

  return this.getHibernateTemplate().executeFind(new HibernateCallback() {

   public Object doInHibernate(Session session)
     throws HibernateException, SQLException {
    return session.createQuery(hql).setFirstResult(start)
      .setMaxResults(maxCount).list();
   }

  });
 }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章