Results 1 to 2 of 2

Thread: Scrollable results...

  1. #1

    Default 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....
    Julian Garcia.

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    You can issue a count using HQL. Please refer to the Hibernate manual for coverage of aggregate functions.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Replies: 6
    Last Post: Sep 22nd, 2006, 09:08 AM
  2. Form and Results on same page
    By biguniverse in forum Web
    Replies: 1
    Last Post: Sep 18th, 2005, 10:45 PM
  3. Caching the results of a method
    By Patrick Vanhuyse in forum Spring-Modules
    Replies: 4
    Last Post: Aug 23rd, 2005, 11:39 AM
  4. Search and results flow problem
    By lnader in forum Web
    Replies: 0
    Last Post: Jun 5th, 2005, 08:46 PM
  5. Scrollable resultset
    By benno in forum Swing
    Replies: 3
    Last Post: Dec 29th, 2004, 04:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •