Hibernate 中出现 users is not mapped 问题
Posted Final_static_杨
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hibernate 中出现 users is not mapped 问题相关的知识,希望对你有一定的参考价值。
Hibernate 中出现 users is not mapped 问题:
解答:HQL语句中表名应该是ORM映射的类名,所以应该改成: (如果是用注解生成实体类,那就是注解的那个类)
String sql = "select u.password from User u where u.username=‘" +user.getUsername()+ "‘";
User.hbm.xml:
<class name="com.lian.bean.User" table="users">
hibernate.cfg.xml:
<mapping resource="com/sxt/User.hbm.xml" />
<class name="com.lian.bean.User" table="users">
hibernate.cfg.xml:
<mapping resource="com/sxt/User.hbm.xml" />
sql 语句查找的是生成的User 类,不是普通的表。 。。。。
执行hibernate报错“node to traverse cannot be null”问题的解决
答应:
一般来说,这是由于使用hibernate 中的HQL做查询时出现了空返回值的错误,很有可能HQL语句本身就写错了。
以上是关于Hibernate 中出现 users is not mapped 问题的主要内容,如果未能解决你的问题,请参考以下文章