开发者

Are you able to prove the Hibernate Lazy-Loading?

开发者 https://www.devze.com 2023-04-06 01:46 出处:网络
I just want to ask, how to prove that hibernate is doing lazy loading . I have code like this : And I try to test lazy loading in hibernate (jpa) with this code :

I just want to ask, how to prove that hibernate is doing lazy loading . I have code like this :

Are you able to prove the Hibernate Lazy-Loading?

And I try to test lazy loading in hibernate (jpa) with this code :

Are you able to prove the Hibernate Lazy-Loading?

Actually, I don't wont to load "alamat" property, because that's a TEXT. But when I try to debug the code, I get the output trace like this :

Are you able to prove the Hibernate Lazy-Loading?

Hibernate is still开发者_StackOverflow中文版 select alamat column, and in the debug veriable, I found that Hibernate is really load alamat column :

Are you able to prove the Hibernate Lazy-Loading?


The Hibernate manual notes:

To enable property level lazy fetching, your classes have to be instrumented: bytecode is added to the original class to enable such feature, please refer to the Hibernate reference documentation. If your classes are not instrumented, property level lazy loading is silently ignored.

How to achieve this is explained in chapter 20.1.8. Using lazy property fetching of the manual. It requires a special build process.


You have to enable bytecode instrumentation to activate lazy loading for properties. If you don't have bytecode instrumentation enabled, Hibernate will ignore any properties about lazy loading (see the docs)

0

精彩评论

暂无评论...
验证码 换一张
取 消