Hibernate in the SSH framework has a user is not mapped problem

When doing SSH framework integration, when doing DAO operations. Only the chekUser() method is called here. The
user is not mapped error is reported during runtime : The
chekUser() method is as follows:
public boolean chekUser(User user){ String hql="from user u where u.id=? and u.name=?"; Query query=getSession(). createQuery(hql); query.setInteger(0, user.getId()); query.setString(1, user.getName()); List list=query.list(); if(list.size()>0&&list! =null){return true;} return false; }







When the above statement made an error, I wrote the HQL statement. The statement I wrote is:
String hql="from user u where u.id=? and u.name=?";

But the table name in the HQL statement should be the class name mapped by the ORM, not the table name you have in the database.
Therefore, change the table name of user in the HQL statement to User, and the change is as follows:
String hql="from User u where u.id=? and u.name=?";
Just change the indication to the ORM mapped class The name
is fine. In the next run, it will not report that there is no xxx is not mapped error.

Guess you like

Origin blog.csdn.net/liulang68/article/details/109245277