Paging:
Before using the hibernate-encapsulated paging method, let's review the native paging practices in Oracle
1 --Paging Query2 --(pageNo-1) *pagesize= start line pageno*pagesize= end line3 Select * from(4 SelectRowNum rm,s.* from(5 Select * fromMyfirsttbOrder byStuagedesc) s6 whereRowNum<=5) 7 whereRm>=2;8
Generally use three layer to do paging query
Now we understand how hibernate provides paging.
Query object provides a method for paging queries
1. Starting Line:
Setfirstresult ();
2. Page display maximum record
Setmaxresult ();
1 // start line (page-1) *col 2 Query.setfirstresult ((1-1)); 3 // maximum number of col per page 4 query.setmaxresults (2);
These two lines of code are placed in Query.list ();
Then you can query the data returned by paging!
Look closely at the QL statements executed by hibernate and you will find the same as the original Zoning page statement!
HQL parameter bindings, unique results, pagination, projection summary (bottom)