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