hibernate:session.load

时间:2012-01-14 01:02:02

标签: java hibernate pojo

我正在学习休眠。为了进行测试,我使用无效密钥调用了session.load。在调试器(JB Idea)中跳过该行后,没有任何反应 - 我希望得到ObjectNotFoundException。比,我打开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

hb如何通知POJO该对象无效。拜托,有人可以推荐我一篇文章,帮助我了解在调试hibernate源码的冒险之前发生了什么。

1 个答案:

答案 0 :(得分:0)

您必须让调试器运行。如果找不到实体,load会抛出异常。如果你查看粘贴的材料,你会看到

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

在第一行。

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

相关问题