org.hibernate.ObjectNotFoundException: No row with the given identifier exists解决

手把手教你解决Realsense D455在ROS下IMU数据不输出的问题(附固件降级指南) 本文详细解析了Realsense D455在ROS环境下IMU数据不输出的问题,提供了固件降级和ROS配置的完整解决方案。通过版本兼容性分析和实战操作指南,帮助开发者快速恢复IMU数据流,优化机器人开发体验。 阅读详情

 

环境

 

Eclipse Jee-indigo + Hibernate 3.2 + JDK 1.6.31

 

问题

 

Hibernate load某个对象出现如下异常:

 

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.oracle.entities.Dictionary#1]
	at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:419)
	at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:154)
	at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:143)
	at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:174)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
	at com.oracle.entities.Dictionary_$$_javassist_0.getName(Dictionary_$$_javassist_0.java)
	at com.oracle.entities.HBTest.testMapLoad(HBTest.java:130)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

 


 

解决

 

报这个异常很大原因是该对象不存在,在testMap这个方法里保存数据,在testMapLoad这个方法里加载数据,思考下为什么数据会不存在。原来是在Dictionary.hbm.xml这个配置文件中做了如下配置:

<property name="hbm2ddl.auto">create</property>

这样配置后就会出现每次执行操作都会重新创建表,在testMapLoad里只加载没插入数据自然就找不到了。于是解决办法这样:先执行testMap这个方法保存数据,然后把

<property name="hbm2ddl.auto">create</property>改成

<property name="hbm2ddl.auto">update</property>,再重新运行testMapLoad自然就不会报此异常了。

 

//代码片段
@Test
	public void testMap(){

		Map words=new HashMap();
		words.put("hello", "你好");
		words.put("ok", "是");
		
		Dictionary dic=new Dictionary();
		dic.setName("eng");
		dic.setPublisher("william");
		dic.setWords(words);
		
		session.save(dic);
	}
	@Test
	public void testMapLoad(){
		Dictionary dic = new Dictionary();
		dic = (Dictionary)session.load(Dictionary.class, 1);
		System.out.println(dic.getName());
		Map words=new HashMap();
		words = dic.getWords();
		System.out.println(words.isEmpty());
		System.out.println(words.get("ok"));
	}


 

参考资料

 

http://yushengxiang.iteye.com/blog/818829

 

http://wj98127.iteye.com/blog/189723

 

立创开源4G+GPS定位系统:基于微信小程序的低成本低功耗追踪方案 本文介绍了一个基于立创开源平台的超小型4G+GPS定位系统方案。该方案采用28mm*28mm主板,集成4G Cat.1通信与GPS定位,通过微信小程序“点灯专家”实现远程追踪管理,具备低成本、低功耗、易于部署的特点,适用于电动车、宠物、资产追踪等多种场景。 阅读详情

相关推荐

Joern实战:从代码导入到Python分析的全流程避坑指南(附常见错误解决方案)

本文详细介绍了Joern静态分析工具从代码导入到Python分析的全流程实践指南,包括环境配置、代码导入技巧、数据库服务优化、Python交互分析及性能调优等关键步骤。特别针对常见错误提供了实用解决方案,帮助开发者高效进行代码安全分析和漏洞挖掘。

weixin_28309571的博客 148

Hibernate报错:org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

报错信息 org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.jbpm.pvm.internal.model.ExecutionImpl#78781405] at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFou...

前行的博客 1886

高频功率放大器的设计实现

摘 要 随着无线通信技术的高速发展,市场对射频电路的需求越来越大,同时对射频电路的性能要求也越来越高。高频功率放大器是位于无线发射级末端的重要部件,为了弥补信号在无线传输过程中的衰耗,要求发射机具有较大功率的输出,通信距离越远,要求的输出功率越大。在高频范围内,为了获得足够大的高频输出功率,就要采用高频功率放大器。 本次课程设计的高频功率放大器的技术指标包括输出功率、效率、功率增益、由于高频频功率放大器的输出功率比较大,耗能比较多,所以工作效率就显得比较重要。本课程设计的高频功率放大器电路由两极功率放大器

qq_43543515的博客 3万+

org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决办法

报错信息: org.hibernate.event.internal.DefaultLoadEventListener onLoad INFO: HHH000327: Error performing load command : org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [c...

向着高亮的地方 1089

实战案例:用多智能体系统模拟房地产市场的架构设计

房地产市场是典型的复杂自适应系统:买方纠结“要不要上车”、卖方盘算“挂多少钱能快速成交”、中介忙着“撮合两边赚佣金”、政府琢磨“怎么调政策稳房价”——每一个参与者的微小决策,最终都会汇聚成“房价暴涨”“成交冰点”这样的宏观现象。传统的计量经济学模型(比如线性回归)假设“所有人都是理性人”,但现实中没人能算清所有变量——你可能因为“同事买了学区房”就跟风,也可能因为“怕失业”而放弃买房。这时候,多智能体系统(MAS)

移动开发前沿的博客 1133

【阿里云大模型高级工程师ACP学习笔记】2.8 部署模型

【摘要】本文主要分享自学阿里云大模型高级工程师 ACP 认证中《2.8 部署模型》的学习笔记。详细介绍学习目标、梳理涵盖的知识点并评估其重要性和难易度,对既重要又困难的知识点进行重点分析,旨在为对阿里云大模型学习和认证感兴趣的读者提供学习思路和经验参考。

davidkorhenn的博客 2067

org.hibernate.ObjectNotFoundException: No row with the given identifier exists 原因及解决方式

原因 对应实体使用了注解 @ManyToOne 数据库中的记录可能由于某一条数据的对外引用时缺失数据,导致对应关系找不到而直接向上抛出异常 org.hibernate.ObjectNotFoundException: No row with the given identifier exists 解决方式 在对应加有注解@ManyToOne 的属性上同时加上 注解 @NotFound(action=NotFoundAction.IGNORE),默认动作是向上抛出异常,这里动作修改为不理会即可 @Man

weixin_44131922的博客 1811

Spring AI RAG 生产级实战:从 0 构建企业智能知识库系统

Spring AI🎯统一的 API 抽象:屏蔽不同 AI 服务商的差异🎯开箱即用的集成:支持主流大模型和向量数据库🎯Spring 生态融合:与 Spring Boot、Spring Data 无缝集成🎯企业级特性:事务管理、监控、安全等RAG 架构:检索 + 增强 + 生成,解决 LLM 局限性Spring AI:统一的 API 抽象,简化 AI 应用开发向量数据库:pgvector 适合中小规模,Milvus 适合大规模文档处理:加载 → 分块 → 向量化 → 存储检索优化。

一起修行,不孤单。这里有编程语言、开发工具、学习方法论和踩坑笔记。用简单的话说复杂的事,陪你从小白到进阶。周更干货,欢迎一起成长! 415

org.hibernate.ObjectNotFoundException: No row with the given identifier exists产生的原因和解决方法...

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34259159的博客 1179

408 | 408常用计算公式与方法 —— 计组篇 汇总

408常用计算公式与方法 —— 计算机组成原理篇 汇总

"You are worthy! You can do it!" 4688

OpenLayers6入门,快速搭建Vue+OpenLayers地图脚手架项目

本章针对Vue初学者,对Vue不熟悉,甚至还不会Vue的入门学生读者。本章会详细讲解从环境到环境的各个步骤,再到使用脚手架快速生成项目,以及添加地图库依赖,编写简单的高德地图显示页面的。如果已有VUE项目或者熟悉VUE的读者可以不用看本章,直接添加ol依赖到VUE项目中即可。

GIS技术方向,GIS地图技术分享(GIS入门、Openlayers教程、Leaflet教程),做最好的GIS地图开发教程。关注博主公众号:eguid 5450

hibernate 常见问题总结

Caused by: org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception

lipingping951462的专栏 2074

js逆向-逆向部分技巧总结

js逆向-逆向部分技巧总结

Deng872347348的博客 2139

关于org.hibernate.ObjectNotFoundException: No row with the given identifier exists 的快捷解决问题

 最近时刻系统出现这样的问题,在网上google了一下,结果是因为数据问题。console错误打印:严重: Servlet.service() for servlet default threw exceptionorg.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.iss.fit.

javafc的专栏 8613

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

org.hibernate.ObjectNotFoundException: No row with the given identifier exists解决办法

hibernate-取消关联外键引用数据丢失抛异常的设置@NotFound hibernate项目里面配了很多many-to-one的关联,后台在查询数据时已经作了健全性判断,但还是经常抛出对象找不到异常: [java] view plain copy org.hibernate.ObjectNotFoundException: No row with the given ident

wan23333的博客 449

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

【hibernate】关于org.hibernate.ObjectNotFoundException: No row with the given identifier exists 的快捷解决问题

最近时刻系统出现这样的问题,在网上google了一下,结果是因为数据问题。 console错误打印: 严重: Servlet.service() for servlet default threw exception org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.iss

天书夜读 1923

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

(已解决)org.hibernate.ObjectNotFoundException: No row with the given identifier exists

原因:有两张表,t1和t2.产生此问题的原因就是t1里做了关联或者(特殊的多对一映射,实际就是一对一)来关联t2.当hibernate查找的时候,t2里的数据没有与t1相匹配的,这样就会报No row with the given identifier exists这个错. 解决方法:以我程序为例,在many-to-one标签里加入not-found="ignore"即可,下面是修改后的代码:

Antonov225的博客 668

org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.zero.space.entity.TblJd#38]解决方法

 现在这个提示说是TblJd这个表中没有特定的标识符行, 是#38 , 一开始是真晕了 , 都不知道是哪里错了。问了下朋友, 这很有可能是 "多(TblFwxx) 对一(TblJd)"  在多(TblFwxx)中有那麽一列数据,但是在 一(TblJd)表中很可能没有那条数据的相关信息.  我一查 靠 还真是, TblJd表中唯独了一个标识列为 38

BBG_0622的专栏 2289

org.hibernate.ObjectNotFoundException: No row with the given identifier exists

1、错误描述Exception in thread "main" org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.you.hibernate.model.TStudentInfo#1] at org.hibernate.internal.SessionFactoryImpl$

游海东的技术专栏 2612

【hibernate】错误org.hibernate.ObjectNotFoundException: No row with the given identifier exists

[INFO ] http-8080-Processor21 2008-03-24 10:15:47,656 org.hibernate.event.def.DefaultLoadEventListener     - Error performing load command org.hibernate.ObjectNotFoundException: No row with the given

天书夜读 2154

No row with the given identifier exists

org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [com.elone.pm.message.pojo.TPublicClass#                                ]; nested

星空 7661

Hibernate之No row with the given identifier exists

严重: Servlet.service() for servlet [dispatcher] in context with path [/operationcenter] threw exception [Request processing failed; nested exception is org.hibernate.ObjectNotFoundException: No row wit

Switch_zyp的专栏 1248
上一篇: SVN检出项目出现Cannot create project to checkout to解决
下一篇: Eclipse下基于Hibernate的Junit Test Case用法示例
Wentasy
博客等级 码龄16年 2390粉丝 672原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值