Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java hibernate:session.load_Java_Hibernate_Pojo - Fatal编程技术网

Java hibernate:session.load

Java hibernate:session.load,java,hibernate,pojo,Java,Hibernate,Pojo,我在学冬眠。为了进行测试,我使用无效键调用了session.load。在调试器(JB Idea)中跳过这一行之后,什么也没有发生——我希望得到ObjectNotFoundException。然后,我打开表达式Eval(alt+F8),结果是: bookFailedLoad = {rs.hibernateTest.model.Book$$EnhancerByCGLIB$$5dd17391@2088}Method threw 'org.hibernate.ObjectNotFoundExceptio

我在学冬眠。为了进行测试,我使用无效键调用了
session.load
。在调试器(JB Idea)中跳过这一行之后,什么也没有发生——我希望得到ObjectNotFoundException。然后,我打开表达式Eval(alt+F8),结果是:

bookFailedLoad = {rs.hibernateTest.model.Book$$EnhancerByCGLIB$$5dd17391@2088}Method threw 'org.hibernate.ObjectNotFoundException' exception. Cannot evaluate rs.hibernateTest.model.Book$$EnhancerByCGLIB$$5dd17391.toString()
CGLIB$BOUND = true
CGLIB$CONSTRUCTED = true
CGLIB$CALLBACK_0 = {org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer@2094}
CGLIB$CALLBACK_1 = null
isbn = null
name = null
publisher = null
publishDate = null
price = 0
chapters = null

hb是如何通知POJO对象无效的。在我开始调试hibernate源代码之前,请有人给我推荐一篇文章来帮助我理解引擎盖下发生了什么

您必须让调试器运行<代码>加载如果找不到实体,则引发异常。如果查看粘贴的材质,您会看到

Method threw 'org.hibernate.ObjectNotFoundException' exception. Cannot evaluate rs.hibernateTest.model.Book$$EnhancerByCGLIB$$5dd17391.toString()
在第一行


就资源而言,Hibernate in Action图书是我买过的最好的图书之一。如果你打算花很多时间在hibernate上,这是值得的。只需确保您获得的书籍版本与您正在使用的hibernate版本相关即可

如果我注释log.info行,则不会引发异常:\n log.info(“bookFailedGet-”+bookFailedGet)\n Book bookFailedLoad=(Book)session.load(Book.class,“PBN456@”)\n//log.info(“bookFailedLoad-”+bookFailedLoad)\n\n}catch(ObjectNotFoundException e){\n log.error(“加载书本失败”,e);\n\n}catch(异常e){\n e.printStackTrace();\n}最后{