The use of hql and the substitution of limit

Source: Internet
Author: User

1.HQL differs from Sql,from must be the name of the class that corresponds to the table reversal in the project.

2. How to generate HQL statements using parameters:

"= session.createquery (HQL); Query.setparameter (0, userId);  // instead of the No. 0 question mark

3.HQL can not write limit, but he has the method can be set, the same effect

Query.setmaxresults (maxCount);  // set the acquired quantity Query.setfirstresult (firstresult);    // settings are obtained from the first few return query.list ();                      // returns the result of the fetch

The use of hql and the substitution of limit

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.