Very strange error, the information is as follows:
Org.hibernate.hql.internal.ast.QuerySyntaxException:User is isn't mapped [select COUNT (*) from the User u where u.username=? an D u.userpassword=? ]
caused By:org.hibernate.hql.internal.ast.QuerySyntaxException:User is not mapped
Similar to the resolution of the error message, I also studied for half a day to finally find the problem
There are two types of errors that occur in this case
1, the configuration file is not loaded into Hibernate's entity list
2, the mapping file's fields are inconsistent with the database fields, or the name inconsistency causes
HQL is a special grammar. is not SQL. You set the Hibernate dialect to the database you use.
The syntax and HQL of SQL are not the same thing.
...... Querysyntaxexception ... Is that the SQL you want is not HQL, syntax error:
1. See if you forgot to add the hibernate mapping file to Hibernate.cfg.xml (when using hibernate) or Applicationcontext.xml
2. Check the fields in the table and whether the fields in the mapping file correspond to one by one
3. Check if the field name uses keywords from the database
4.HQL statement is correct
Hql:hibernate Query Language Hibernate is equipped with a very powerful query language that looks much like SQL. But instead of being fooled by the similarity in grammatical structures, HQL is very conscious of being designed as a fully object-oriented query that can understand concepts such as inheritance, polymorphism, and correlation.
So this time you have to carefully check your written HQL statement, must be the object query, especially "TableName" do not write the table you want to query, but the object of the query
Like what:
Public long Gettypecount (patent patent) {
String hqlstring = "SELECT count (*) from patent as P where P.type = '" +patent.gettype () + "'";
Query query = this.getsession (). CreateQuery (hqlstring);
Long Count = 0;
Count = ((number) Query.uniqueresult ()). Intvalue ();
return count;
}
Patent is an object
The database table name is patent if written as String hqlstring = "SELECT count (*) from Patent as P where P.type = '" +patent.gettype () + "'";
Certainly is the query does not produce the result, remember!
SSH Integration Error: Org.hibernate.hql.internal.ast.QuerySyntaxException:User is not mapped[...]