user is not mapped [from user where userName=? and password=?]; nested exception is org.hibernate.hq

SSH关于通过User登录user is not mapped [from user where userName=? and password=?]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where userName=? and password=?]

看图

在这里插入图片描述
查看dao中的代码

List<User> list= find("from user where userName=? and password=?",new String[]{userName, password});
        return list.get(0);

这里的from user 这个user代表表明 ,这样是不可以的

下面正确写法将user换成User 。from是针对User这个类,而不是这个表user:

List<User> list= find("from Userwhere userName=? and password=?",new String[]{userName, password});
        return list.get(0);

Lucas科技:
csdn博客:https://blog.csdn.net/qq_43084651
github:https://github.com/LLLLucas/-

猜你喜欢

转载自blog.csdn.net/qq_43084651/article/details/89163497