about using the HQL statement to query for the presence of XXX is not mapped when consolidating in the SSH framework

Source: Internet
Author: User
Tags aliases

In the integration process of SSH framework, novice will often encounter this problem. When we use the HQL statement query, the console error: XXX is not mapped. And at this time, many feel good English students will be dizzy. It then starts by checking that the mapping file for the entity class is *.hbm.xml correct, adding the mapping file to the spring configuration file, and so on. Then highlight a pass, still not effective.

Let's get down to the chase. As we all know, Hibernate is a framework that allows us to fully object-oriented programming. In other words, when we operate on database data, we actually pass the entity class. There are 3 ways to query in hibernate:

(1) Querying the data directly as an object via the Get or Load method. This usage is typically used to query all properties.

(2) query by using the HQL statement. At this point we need to query the data by using statements like GetSession (). CreateQuery (HQL).

(3) query by using SQL statement. This method is similar to using HQL, which is the getsession (). Createsqlquery (HQL) statement.

Since we are querying, we are using HQL. So, the from behind our HQL statement should be followed by the object name, not the data table name. Another thing is to pay attention to capitalization. If you use aliases, you can use aliases to query a value that matches a condition by using the name of the entity class property, without using an alias, and the query column is also the property name. This will not have the above error.

about using the HQL statement to query for the presence of XXX is not mapped when consolidating in the SSH framework

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.