请教下面是什么错误?

eevsee 2017-07-26 08:24:20
七月 26, 2017 3:12:35 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [default] in context with path [/plat] threw exception [org.hibernate.HibernateException: HQL:from User as o where o.loginName = 'admin' synax error.User is not mapped [from User as o where o.loginName = 'admin']; nested exception is org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User as o where o.loginName = 'admin']] with root cause
org.hibernate.HibernateException: HQL:from User as o where o.loginName = 'admin' synax error.User is not mapped [from User as o where o.loginName = 'admin']; nested exception is org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User as o where o.loginName = 'admin']



SQL是这样,String Sql = "from User as o where o.loginName = '" + loginName + "'";
我hql是写的是PO对象,不是table名,感觉没错吖,百度了一下实在没找解决方法,请问是什么错误,怎么解决?
...全文
252 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
mmqw 2017-07-28
  • 打赏
  • 举报
回复
User表的映射有问题,看下hibernate的配置文件
德弗特洛斯 2017-07-28
  • 打赏
  • 举报
回复
你贴出的SQL语句是不是有问题?最外层用双引号,里面就应该用单引号了呀。
lifewell1 2017-07-27
  • 打赏
  • 举报
回复
直接 写from User where loginName = 不用加 o hql解析的时候会自动生成一个表别名
110成成 2017-07-27
  • 打赏
  • 举报
回复
检查下你的mappingResources 配置
xiwei_2086 2017-07-27
  • 打赏
  • 举报
回复
看配置文件。
achiman 2017-07-27
  • 打赏
  • 举报
回复
loginName 应该不是user的主键吧,返回类型是否正确,可以看下
eevsee 2017-07-26
  • 打赏
  • 举报
回复
引用 1 楼 zc881124 的回复:
有隐射吗?看错误提示实体类没有隐射
有吖,但是User.hbm.xml也看不出有什么错误
110成成 2017-07-26
  • 打赏
  • 举报
回复
有隐射吗?看错误提示实体类没有隐射

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧