hibernate分页

xiaoxiao2026-01-02  4

三个参数, 第一个是HQL语句,如from EntryObject 第二个是从第几条记录开始 第三个是分页的页显示条数大小 find("from EntryObject",1,20); 表示查询Users 表,从第1条记录开始,共查询出20条记录 public List find( final String hsql, final int firstRow, final int maxRow) throws Exception { return getHibernateTemplate().executeFind( new HibernateCallback() { public Object doInHibernate(Session s) throws HibernateException, SQLException { Query query = s.createQuery(hsql); query.setFirstResult(firstRow); query.setMaxResults(maxRow); List list = query.list(); return list; } }); }
转载请注明原文地址: https://www.6miu.com/read-5041937.html

最新回复(0)