简体   繁体   English

休眠:session.load

[英]hibernate: session.load

I'm learning hibernate. 我正在学习休眠。 To make a tests I invoked session.load with invalid key. 为了进行测试,我使用无效密钥调用了session.load After I step over that line in debugger (JB Idea), nothing happen - I expected to get ObjectNotFoundException. 在调试器(JB Idea)中越过这一行之后,什么都没发生-我期望得到ObjectNotFoundException。 Than, I opened Expression Eval (alt+F8) and result was: 然后,我打开了Expression 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

How did hb inform POJO that object is not valid. hb如何通知POJO对象无效。 Please, could someone recommend me an article to help me understand what's happening under the hood before I stock in adventure of debugging hibernate source. 拜托,有人可以向我推荐一篇文章,以帮助我了解如何进行休眠源调试之前的了解。

You have to let the debugger run. 您必须让调试器运行。 load throws an exception if the entity is not found. 如果找不到该实体, load会引发异常。 If you look in the material you pasted, you see 如果您查看粘贴的材料,就会看到

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

on the first line. 在第一行。

As far as resources are concerned, the Hibernate in Action books is one of the best books I have ever bought. 就资源而言,《 Hibernate in Action》书籍是我买过的最好的书籍之一。 Well worth it if you are going to spend a lot of time with hibernate. 如果您要花很多时间进行休眠,那是值得的。 Just make sure the version of the book you get is relevant to the version of hibernate you are using. 只要确保您获得的书的版本与您使用的休眠版本相关即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM