HQL parameter bindings, unique results, pagination, projection summary (bottom)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.