org.hibernate.ObjectNotFoundException: No row with the given identifier exists
来源:互联网 发布:使命召唤网络异常 编辑:程序博客网 时间:2024/05/17 05:52
问题产生原因:
有一个对象A,关联了对象B ,关联关系可以使 ManyToOne,OneToOne 等,如果我们在数据库中清除了B对象,但是B对象还在A表中存在外键,这时候Hibernate检查这个关系的时候,会报出这个异常。但是A与B在数据库 为范围内不能耦合过紧,只能pojo中建立关联关系,此时要注意,清除A表中的外键,可以解决此问题,一般的垃圾数据会造成业务系统不能正常运转。
第二个原因:
查询的时候,假设对象A与B有着一对一的关系,一般我们配置
@OneToOne
@JoinColumn(name = "xxx"),如果B被删除了,但是A中还维护这个外键关系
要配置
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "xxx")
的模式,不知道为什么默认不是lazy的,还要配置一下fetch = FetchType.LAZY
本要急于测试所以直接设置为不关联not-found="ignore"
Hibernate的many-to-one的元素的一个属性:not-found今天看Hibernate Reference,看到多对一关系时,看到mant-to-one元素有一个属性:not-found。用来指定引用的外键不存在时将如何处理:
有一个对象A,关联了对象B ,关联关系可以使 ManyToOne,On
第二个原因:
查询的时候,假设对象A与B有着一对一的关系,一般我们配置
@On
@JoinColumn(name = "xxx"),如果B被删除了,但是A中还维护这个外键关系
要配置
@On
@JoinColumn(name = "xxx")
的模式,不知道为什么默认不是lazy的,还要配置一下fetch = FetchType.LAZY
本要急于测试所以直接设置为不关联not-found="ignore"
Hibernate的many-to-one的元素的一个属性:not-found今天看Hibernate Reference,看到多对一关系时,看到mant-to-one元素有一个属性:not-found。用来指定引用的外键不存在时将如何处理:
- exception(默认)抛出异常
- ignore 忽略
以前不知道有这个属性,Hibernate就采用默认的抛出异常来处理了。经常出现显示一个项目的列表时没有数据。
0 0
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists .
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- rg.hibernate.ObjectNotFoundException: No row with the given identifier exists
- 【hibernate】错误org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- 【hibernate】关于org.hibernate.ObjectNotFoundException: No row with the given identifier exists 的快捷解决问题
- 【hibernate】org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
- 关于org.hibernate.ObjectNotFoundException: No row with the given identifier exists 的快捷解决问题
- 关于org.hibernate.ObjectNotFoundException: No row with the given identifier exists 的快捷解决问题
- 忽略org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- 关于org.hibernate.ObjectNotFoundException: No row with the given identifier exists 的快捷解决问题
- IntelliJ IDEA 目录技巧
- 二十多种设计模式
- TCP网络编程--非阻塞accept和非阻塞connect
- Memcached Java Client API
- 嵌入式 linux下kernel代码中设备驱动模型之bus
- org.hibernate.ObjectNotFoundException: No row with the given identifier exists
- Vmware中的Linux系统通过NAT方式联网
- C# WinForm TreeView改变选中节点颜色,失去焦点时选中节点仍突显。
- centos7(minirnal)版安装——nginx
- 嵌入式 linux下kernel代码中设备驱动模型之device-driver
- bnu oj 34985 Elegant String (矩阵+dp)
- Xcode6与Xcode5版本之间控件差异
- [转] Trie树详解及其应用
- android intent action 介绍大全