现在的位置: 首页 > 综合 > 正文

user is not mapped

2013年04月17日 ⁄ 综合 ⁄ 共 416字 ⁄ 字号 评论关闭

用Hibernate实现一个用户的登陆过程,当我在JSP的登陆页面输入姓名和密码,点登陆后,显示登陆失败页,在服务器里显示如下的错误信息:
    org.hibernate.hql.ast.QuerySyntaxException: user is not mapped. [from User where UserNO=? and Password=?]

因为Hibernate是对类查询的
在hql="select * from user u where u.username='"+username+"' and u.password='"+password+"'中,

user是数据库中的表,而user对应的类是User.java,现在只需要将from user改为from User,同时不用在出现select *即可,即
hql="from User u where u.username='"+username+"' and u.password='"+password+".

抱歉!评论已关闭.