Castle Learn notes----implement complex queries with HQL statements

Source: Internet
Author: User

To implement a slightly more complex query in the ActiveRecord, we cannot use the Find (ID), findall () two static methods, then we need to use the HQL statement to implement, In the usual use of castle I think we all notice under the Activerecordbase class, because only provide find (ID), findall () such as two static query methods, these two methods in our query is not enough, Still cannot solve some complex queries in the actual development, this aspect ActiveRecord has provided the HQL language support for us.

I. Introduction to the HQL statement

The HQL full name is Hibernate query Language, which is a fully object-oriented query language. Let's take a look at some of the most basic uses of HQL (like SQL):

The FROM clause--------> such as: From name, also desirable for aliases such as from name as name, or as, such as from name name.

SELECT clause-----> such as: Select Name from TableName.

WHERE clause---> such as: From TableName as TN where TN. The Name is not null.

Use aggregate functions--> such as: Select * from Table as T.

......

For more hql use, please refer to the relevant information, this is not described in detail.

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.