org.hibernate.ObjectNotFoundException: No row with the given identifier exists解决办法
hibernate-取消关联外键引用数据丢失抛异常的设置@NotFound
hibernate项目里面配了很多many-to-one的关联,后台在查询数据时已经作了健全性判断,但还是经常抛出对象找不到异常:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists
因为系统给用户使用过程中库表的数据会常发生变化,最常见的是人员变化,原先引用的User 在库表没了,hibernate 多对一关联,多的这端引用的一的那端,如此引用值在一的那端找不到数据,默认就会抛出异常;而后台判断控制不了此问题。解决办法:
 在many-to-one的这端加上属性:not-found=ignore
hibernate many-to-one的属性not-found,用来指定引用的外键不存在时如何处理:
exception(默认)抛出异常
ignore 忽略
注解 @NotFound(action=NotFoundAction.IGNORE)
实列
@ManyToOne(cascade={CascadeType.PERSIST},targetEntity=QeTopic.class)
@JoinColumn(name="topic_id",updatable=false)
@NotFound(action=NotFoundAction.IGNORE)
private QeTopic qeTopic;
配置文件 在<many-to-one>中设置not-found="ignore"
也可以将垃圾数据从数据库删掉
org.hibernate.ObjectNotFoundException: No row with the given identifier exists解决办法的更多相关文章
- Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法
		
报错信息: org.hibernate.event.internal.DefaultLoadEventListener onLoad INFO: HHH000327: Error performing ...
 - org.hibernate.ObjectNotFoundException: No row with the given identifier exists
		
维护老系统时出现的问题,出现的原因我简述一下: table1与table2是关联表,T1中有T2的主键 "T1_id",当T1中的 "T2_id" 不为null ...
 - org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.zhuoshi.entity.Dep#1]
		
报错信息: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.zhuoshi.e ...
 - org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [cn.facekee.cms.entity.CmsFansgroup#195]
		
刚开始报错还是报的稀奇古怪的错误,让我纠结了好久,再三检查报错的位置,发现并没有错误,最后认真分析查看每行报错的信息才找到如题所述的错误!!!!! 报这种错误的原因可能是POJO映射文件中的字段和数据 ...
 - Hibernate错误——No row with the given identifier exists
		
错误 是用的是Hibernate自动建立的数据表,在进行数据库操作时,出现错误No row with the given identifier exists 解决 关系数据库一致性遭到了破坏,找到相关 ...
 - Hibernate常见问题 No row with the given identifier exists问题的解决办法及解决
		
(1)在学习Hibernate的时候遇到了这个问题"No row with the given identifier exists"在网上一搜看到非常多人也遇到过这个问题! 问题的 ...
 - 关于Hibernate中No row with the given identifier exists问题的原因及解决
		
今天遇到一个bug,截图如下 有两张表,table1和table2.产生此问题的原因就是table1里做了关联<one-to-one>或者<many-to-one unique=&q ...
 - Hibernate3.x异常No row with the given identifier exists 解决方法
		
这个异常是在 多对一关系映射时,一方表中对应的数据不存在才抛出的.原来的配置: <many-to-one class="com.art.model.user.UserInfo" ...
 - (转)收集:Hibernate中常见问题 No row with the given identifier exists问题的原因及解决
		
Hibernate中No row with the given identifier exists问题的原因及解决 产生此问题的原因: 有两张表,table1和table2.产生此问题的原因就是tab ...
 
随机推荐
- ABAP 7.53 中的ABAP SQL(原Open SQL)新特性
			
S/4 HANA 1809 已经在上月发布,随之而来的是ABAP 7.53. 本文是更新文档中ABAP SQL的部分的翻译. 本次更新的内容较多,主要内容包括:Open SQL更名为ABAP SQL: ...
 - .NET CORE学习笔记系列(2)——依赖注入[4]: 创建一个简易版的DI框架[上篇]
			
原文https://www.cnblogs.com/artech/p/net-core-di-04.html 本系列文章旨在剖析.NET Core的依赖注入框架的实现原理,到目前为止我们通过三篇文章从 ...
 - spring MVC处理请求过程
			
spring MVC处理请求过程 首先看一个整体图 简单说下各步骤: handlerMapping handlerMapping将请求映射到处理器,即图中的HandlerExecutionChain. ...
 - 好程序员web前端分享18个用CSS制作出来的东西
			
好程序员web前端分享18个用CSS制作出来的东西,与流行的看法相反,CSS不仅仅是用来提供一个WEB页面的基本风格,以使它看起来更有吸引力.还有很多其他的事情,CSS也可以做的很好.由于它创建动画和 ...
 - 【Windows】+ win10 通过KMS激活
			
win10激活到期 通过KMS再次激活(亲测有效):http://www.xitongcheng.com/jiaocheng/win10_article_44435.html
 - 《PyQt5快速开发与实战了》正式发售 !!!
			
<PyQt5快速开发与实战>正式出售了,该书是国内第一本介绍PyQt5的书籍.是两位一线工程师耗费一年的心血.本书github网址:https://github.com/cxinping/ ...
 - 几种c++字符串split 函数实现的比较
			
文中的字符串split函数功能是 从字符串中按照特定的分隔符进行分割,分割的结果保存到std::vector中. 1. strtok实现 std::vector<std::string> ...
 - Leetcode 27. Remove Element(too easy)
			
Given an array and a value, remove all instances of that value in-place and return the new length. D ...
 - 循环语句--do...while
			
do...while循环 格式: 执行流程 执行顺序:①③④>②③④>②③④…②不满足为止. ①负责完成循环变量初始化. ②负责判断是否满足循环条件,不满足则跳出循环. ③具体执行的语句 ...
 - Python dict和set的实现原理
			
在python的dict中间进行查找某个key操作时,查找所需时间不会随着dict中键值对数量增多而变长,(时间复杂度为O(1))但是list中就会(时间复杂度为O(N)),这是因为list查询实现的 ...