Bytecode enhancement

I have successfully setup build time bytecode enhancement using maven plugin. It seems all associations that are marked as ManyToOne(lazy=true) are ignored, and require additional annotation lazytoone(value=LazyToOneOption.NO_PROXY). Will this be changed in version 6? Having additional annotation on every manytoone is cumbersome. Also, I noticed that any ManyToOne on Embedded entities are also eagerly loaded, even with the LAZYTOONE annotation. Is that a bug? These are lazy loaded w/out bytecode enhancement.
thanks

Hi James,
as specified in the note of the user guide paragraph https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#BytecodeEnhancement-lazy-loading , the lazytoone(value=LazyToOneOption.NO_PROXY) is required. Removing this requirement in 6 is something we are taking into consideration.

About the issue with Embeddable it sounds like a bug, you can try to enable the hibernate.bytecode.allow_enhancement_as_proxy property (see https://in.relation.to/2019/07/30/bytecode-proxy/) it should avoid the eagerly loading.

1 Like

To follow up a bit on what Andrea said…

We will remove the need to specify NO_PROXY in 6. We will not remove that option however. Granted it is tiny, but there is an overhead with unwrapping a proxy into its (even lazy) “target” - some users will want to avoid that. So in 6, if the association is to an entity that has bytecode-enhanced laziness we will assume NO_PROXY

1 Like