查看文章
 
org.hibernate.hql.ast.QuerySyntaxException: role is not mapped.的错误解决
2009-02-14 10:32

org.hibernate.hql.ast.QuerySyntaxException: role is not mapped.

mapped是映射的意思

我在用List<Role> rolelist=currencydao.findByHql("from role order by addDate desc"); 查询时,老是报

[10:25:16.625] {http--8083-15} javax.servlet.ServletException: org.hibernate.hql.ast.QuerySyntaxException: role is not mapped. [from role order by addDate desc]
原因:我这个语句“select * from role order by addDate desc”在SQL中查询是正确的,可是在这里就不对了。因为Hibernate是对类查询的 ,所以在这里的HQL语言要面向对象 Role.java 进行操作,把role改成Role就可以了。
---------------------------

类似问题:

org.hibernate.hql.ast.QuerySyntaxException is not mapped

我用Hibernate实现一个教师的登陆过程,当我在JSP的登陆页面输入姓名和密码,点登陆后,显示登陆失败页,在服务器里显示如下的错误信息:
org.hibernate.hql.ast.QuerySyntaxException: teachers is not mapped. [from teache rs tea where tea.name=:teaName and tea.password=:teaPassword]

答:HQL错了
因为 Hibernate是对类查询的
在hql="from teachers tea where tea.name=:teaName and tea.password=:teaPassword";中,
teachers是数据库中的表,而teachers对应的类是Teachers.java,现在只需要将teachers改为Teachers就可以了,即
hql="from Teachers tea where tea.name=:teaName and tea.password=:teaPassword";

类别:Java||添加到搜藏 |分享到i贴吧|浏览(6457)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu