SSH框架中hibernate 出现 user is not mapped 问题
来源:互联网 发布:草根吧源码 编辑:程序博客网 时间:2024/06/03 19:27
在做SSH框架整合时,在进行DAO操作时。这里就只调用了chekUser()方法。运行时报
user is not mapped 错误 :
chekUser()方法如下:
public boolean chekUser(User user){
String hql="from user u where u.id=? and u.name=?";
Query query=getSession().createQuery(hql);
query.setInteger(0, user.getId());
query.setString(1, user.getName());
List list=query.list();
if(list.size()>0&&list!=null){return true;}
return false;
}
上面的语句出错时因为自己写了HQL的语句,其中我写的语句是:
String hql="from user u where u.id=? and u.name=?";
但是在HQL语句中表名应该是ORM映射的类名 ,而不是你在数据库中的表名。
所以将HQL语句中的user的表名改为User即可,改后如下:
String hql="from User u where u.id=? and u.name=?";
只要将表明换成ORM映射的类名就可以了
在次运行就不会报没有 xxx is not mapped的错了。
上面的语句出错时因为自己写了HQL的语句,其中我写的语句是:
- SSH框架中hibernate 出现 user is not mapped 问题
- SSHE框架中hibernate出现user is not mapped问题
- Hibernate或者ssh三大框架中出现 XXXX is not mapped问题
- hibernate:运行时出现user is not mapped问题
- Hibernate 中出现 users is not mapped 问题
- Hibernate 中出现 XXXX is not mapped 问题
- Hibernate 中出现 users is not mapped 问题
- Hibernate 中出现 users is not mapped 问题
- Hibernate 中出现 users is not mapped 问题
- Hibernate 中出现 GOOD is not mapped 问题
- Hibernate 中出现 XXXX is not mapped 问题
- Hibernate: user is not mapped
- hibernate 出现 is not mapped 问题
- hibernate 出现***is not mapped
- Hibernate Hql 查询出现 USER is not mapped [FROM USER WHERE
- Hibernate Hql 查询出现 USER is not mapped [FROM USER WHERE
- 解决Hibernate使用HQL查询出现is not mapped问题
- Hibernate 中出现 QuerySyntaxException: users is not mapped
- uva 548 Tree
- C++数据结构--队列的应用--基数排序
- Tomcat性能调优方案
- 数据库日记清除
- Datalogics 推出适用于 Adobe PDF Library(TM) 的 .NET 接口
- SSH框架中hibernate 出现 user is not mapped 问题
- C++中的new、operator new与placement new
- wikioi1040 统计单词个数
- 数据库日记清除:DBCC SHRINKFILE
- Genymotion无法启动
- 顺序访问内存,提高程序性能
- python学习之路四(类和对象1)
- 给空白筛子涂色,保证两个筛子投掷数字每一个和的概率相等
- 面试题26:复杂链表的复制