简体   繁体   中英

hibernate: session.load

I'm learning hibernate. To make a tests I invoked session.load with invalid key. After I step over that line in debugger (JB Idea), nothing happen - I expected to get ObjectNotFoundException. Than, I opened Expression Eval (alt+F8) and result was:

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. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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