HQL Query Statements

Source: Internet
Author: User

This article for Bo Master original, allow reprint, but please declare the original address: http://www.coselding.cn/blog/8/8-142.html

  1. The HQL syntax is structured like a SQL statement,
  2. Query query = session.createquery (String HQL); A query object is obtained through a HQL query statement, which can get the result set of the HQL statement.
  3. Query supports internal links, left and right connections, supports direct queries to hibernate entity classes, and directly uses "." For other B entity class members in a entity class. To be called as a column of a entity class (an association relationship has been set);
  4. From,select,where,order By,group By, the subquery is the same as SQL, the specific query document
  5. The serial number is starting from 0 bits.
  6. Query.list data run out to Session.close ()
  7. Query supports normal SQL, HQL, EJBQL. Function Strength: nativesql>hql>ejbql>qbc>qbe.
  8. HQL placeholder: ": Parameter name" or "?", replacing the parameters in the placeholder directly with the Setinteger method.
  9. Paging: Setmaxresults: Sets the number of bars per page, Setfirstresult settings start from the first.
  10. You can return the property values for each column like SQL, and each property value is returned as an object, forming an object array. You can also compose a temporary wrapper object for these returned column values to save, and write "new class qualified name" in HQL.
  11. HQL with "join" to navigate the connection, join T.topic cannot use join Topic, because which object in T is to be set and Topic to connect.
  12. Query.uniqueresult (): Returns the query unique object.
  13. COUNT (*) returns a long type, with Query.uniqueresult ().
  14. Aggregate functions, Between...and, in, NOT null, is empty, is not empty, like, exists, not exists. the exists performs more efficiently than in.
  15. EJBQL commonly used functions, variable case, connection string, go space, average, sum, and so on. (Not important)
  16. The date is directly compared with >, <, and so on.
  17. Group BY, have, subquery, all functions.
  18. Namequery: Name the query, then call directly with key, @NameQueries define the named query, centralize the query statement management.
  19. Createsqlquery (): Use normal SQL statement query, return sqlquery, @NameNativeQueries.
  20. QBC (query by criterial): The criteria constraint set, with the restrictions to produce the query constraints, that is, where the clause, the equivalent of the SQL statement becomes object-oriented!!! Detachedcriteria: The object that creates the binding session can be separated from session management.
  21. QBE (Query by Example): Example e = Example.create (object obj), creating a constraint object that can be added as a constraint object of criteria to make object-oriented more thorough.

This article for Bo Master original, allow reprint, but please declare the original address: http://www.coselding.cn/blog/8/8-142.html

HQL Query Statements

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.