Raible's Wiki
Raible Designs AppFuseHomepage- Korean - Chinese - Italian - Japanese QuickStart Guide User Guide Tutorials Other ApplicationsStruts ResumeSecurity Example Struts Menu
Set your name in
UserPreferences
Referenced by
JSPWiki v2.2.33
Hide Menu |
This is version 8.
It is not the current version, and thus it cannot be edited. Hibernate Pagination
Here's an entry from the Hibernate FAQ that shows one way of doing this: Here is Gavin Kings Blog on a Paging class. Another entry relevant to this issue on the Hibernate site Hibernate Pagination Query q = s.createFilter( collection, "" ); // the trivial filter q.setMaxResults(PAGE_SIZE); q.setFirstResult(PAGE_SIZE * pageNumber); q.setProjection( Projections.alias( Projections.rowCount(), "numResults" ) ) List page = q.list(); Do NOT use: ScrollableResults scrollableResults = query.scroll(); scrollableResults.last(); rowCnt = scrollableResults.getRowNumber(); as most drivers (including Oracle) basically read all the data on the client side in order to calculate the number of rows. Hibernate 3 has added the ability of adding projections like count(*) w/ aliases to the Query. NOTE: If you are looking to encorporate Hibernate pagination with DisplayTag, there are a number of patch offerings on the DisplayTag JIRA. Hopefully, if enough people vote for them, DisplayTag will soon support pagination by calling the server side DAO to retrieve a page of results at a time! At the momment, DisplayTag loads all results which is not efficient for large lists.
|