I am using daos with hibernateTemplate. I am having problems with ScrollableResults. My method looks like:
This works fine, but now for the sake of pagination, I also need the number of all results in the table. How can I get this using HT? What are best practices for pagination using hibernate, hibernateTemplate and the dao pattern?Code:public List getObjects(int firstResult int maxResults) { final int finalFirstResult = firstResult; final int finalMaxResults = maxResults; return getHibernateTemplate().executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { StringBuffer sb = new StringBuffer(100); sb.append("select distinct object "); sb.append("from PersistentObject object"); Query query = session.createQuery(sb.toString()); query.setFirstResult(finalPrimerResultado); query.setMaxResults(finalmaximoNumeroResultados); List list = query.list(); return list; } }); }
Thanks....


Reply With Quote