Announcement Announcement Module
Collapse
No announcement yet.
Scrollable results... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scrollable results...

    I am using daos with hibernateTemplate. I am having problems with ScrollableResults. My method looks like:
    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;
                }
            });
        }
    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?

    Thanks....

  • #2
    You can issue a count using HQL. Please refer to the Hibernate manual for coverage of aggregate functions.

    Comment

    Working...
    X