-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Criteria class and Pagination
PostPosted: Mon Sep 27, 2004 12:07 pm 
Regular
Regular

Joined: Mon Sep 20, 2004 8:42 am
Posts: 58
Location: Boston, US
Hibernate version: 2.1.6

I need to display a table in a Web UI that supports
-sorting
-filtering on one or more columns
-pagination

The table is based on a single domain Entity class. To accomplish this I'm building the query dynamically using a generic routine that uses the hibernate Criteria class. The filter, sort and paging info is passed to the routine the builds the 'Criteria' using the Expression and Order helper classes. All this works well.

However I also have the requirement that the table in the UI display the total number of pages. The Pagination solution in the Hibernate blogs (http://blog.hibernate.org/cgi-bin/blosx ... ation.html) does not address this however its pretty simple to do when working with the Query class. One can simply call
Code:
query.scroll()
to get a
Code:
ScrollableResults results
instance. Working with the 'results' instance one can set the start position and results size based on the table page number and page size and finally determine the number of pages navigating to the last record
Code:
results.last()
and then calling
Code:
results.getRowNumber().


Unfortunately when working with the Criteria API, I cannot get a handle to the ScrollableResults and therefore can't determine the total number of records. Am I missing a way to determine the total number of records using the scrollable resultset feature when working with the Criteria API?

I was looking for an API on the Criteria class that looks like

ScrollableResults scroll() or
Query query()

Thanks,
Sanjiv


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.