No row with the given identifier exists
来源:互联网 发布:js点击空白关闭弹出层 编辑:程序博客网 时间:2024/06/11 02:03
出现异常org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists
一.
No row with the given identifier exists 解决方法
有两张表,a和b.产生此问题的原因就是a里做了关联<one- to-one>或者<many-to-one unique="true">(特殊的多对一映射,实际就是一对一)来关联b.当hibernate查找的时候,b里的数据没有与a相匹配的,这样 就会报No row with thegiven identifier exists这个错.(一句话,就是数据的问题!)
假如说,a里有自身的主键id1,还有b的主键id2,这两个字段.
如果hibenrate设置的单项关联,即使a中的id2为null值,b中id2中有值,查询都不会出错.但是如果a中的id2字段有值,但是这个值在b中主键值里并没有,就会报上面的错!
如果hibernate是双向关联,那么a中的id2为null值,但是b中如果有值,就会报这个错.这种情况目前的解决办法就是改成单项关联,或者把不对应的数据改对!
假如说,a里有自身的主键id1,还有b的主键id2,这两个字段.
如果hibenrate设置的单项关联,即使a中的id2为null值,b中id2中有值,查询都不会出错.但是如果a中的id2字段有值,但是这个值在b中主键值里并没有,就会报上面的错!
如果hibernate是双向关联,那么a中的id2为null值,但是b中如果有值,就会报这个错.这种情况目前的解决办法就是改成单项关联,或者把不对应的数据改对!
二.
hibernate的一些常见的错误
No row with the given identifier exists
表示你现在查询的对象所关联的对象有问题,一般是因为数据的问题(该对象所关联的对象找不到)
Caused by: org.dom4j.DocumentException: Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence.
如果出现这行错误说明你的xml配置文件有不规范的字符,检查下。
net.sf.hibernate.MappingException: Error reading resource: hibernate/Hello_Bean.hbm.xml
如果出现这行错误说明你的hibernate的XML配置文件有错
net.sf.hibernate.MappingException: Resource: hibernate/Hello_Bean.hbm.xml not found
如果出现这行错误说明hibernate的XML配置文件没有找到,你应该把XML文件放在与你的类文件同个目录下,本文中是放在hibernateclasseshibernate目录下,也就是跟Hello_Bean.class类文件一起。
net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property name in class hibernate.Hello_Bean
如果出现这行错误说明你的xml文件里设置的字段名name的值与Hello_Bean.java类里的getXXX或setXXX方法不一致。
net.sf.hibernate.HibernateException: JDBC Driver class not found: org.gjt.mm.mysql.Driver
如果出现这行错误说明你的MYSQL驱动没有加进JB库里或者不在CLASSPATH里。
No row with the given identifier exists
表示你现在查询的对象所关联的对象有问题,一般是因为数据的问题(该对象所关联的对象找不到)
Caused by: org.dom4j.DocumentException: Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence.
如果出现这行错误说明你的xml配置文件有不规范的字符,检查下。
net.sf.hibernate.MappingException: Error reading resource: hibernate/Hello_Bean.hbm.xml
如果出现这行错误说明你的hibernate的XML配置文件有错
net.sf.hibernate.MappingException: Resource: hibernate/Hello_Bean.hbm.xml not found
如果出现这行错误说明hibernate的XML配置文件没有找到,你应该把XML文件放在与你的类文件同个目录下,本文中是放在hibernateclasseshibernate目录下,也就是跟Hello_Bean.class类文件一起。
net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property name in class hibernate.Hello_Bean
如果出现这行错误说明你的xml文件里设置的字段名name的值与Hello_Bean.java类里的getXXX或setXXX方法不一致。
net.sf.hibernate.HibernateException: JDBC Driver class not found: org.gjt.mm.mysql.Driver
如果出现这行错误说明你的MYSQL驱动没有加进JB库里或者不在CLASSPATH里。
- No row with the given identifier exists
- No row with the given identifier exists
- No row with the given identifier exists
- No row with the given identifier exists
- No row with the given identifier exists:
- No row with the given identifier exists
- No row with the given identifier exists
- No row with the given identifier exists
- No row with the given identifier exists
- No row with the given identifier exists:
- no row with the given identifier exists
- No row with the given identifier exists
- No row with the given identifier exists:
- Hibernate: No row with the given identifier exists
- 遇到了 No row with the given identifier exists
- No row with the given identifier exists 解决方法
- Hibernate: No row with the given identifier exists错误
- No row with the given identifier exists 解决方法
- 百度校招2012应届生面试总结(一)
- WordPress中的cookie机制
- linux下线程创建失败问题
- printf的特殊用法
- 《python tutorial》--python 学习第三天
- No row with the given identifier exists
- rpm安装总结
- iis 访问数据元失败!或出现 xml错误解决方法!
- C语言中字符对齐(内存对齐)问题(测试环境visual studio 2010)
- 分组报文,协议和Socket的概念
- activePDF Toolkit使用教程:如何添加书签
- Android开发笔记3:Service基础
- 交换排序法,进行int类型数组升序的排列
- 浅谈Android五大布局