How to see if Bytecode Enhancement works or not


I’m using bytecode enhancement in my project to ensure that all associations are lazily loaded. I added the maven plugin to my pom-file. However, it seems like it does not affect my testing, some associations are still eagerly loaded even though I have the flag “enableLazyInitialization” is set to true. Is there something more I need to do in order to activate the bytecode enhancement with my entities in the code to make the associations be lazy loaded? I have tried setting all the entities manually to lazy aswell, but the same problem as when not using the tool occurs, OneToOne-associations are eagerly loaded. The documentation does not mention anything more than adding the plugin to the pom-file. Is there some way I can ensure that the tool is up and running?

Thanks in advance.

Are your classes instrumented properly. Just decompile them to make sure they were enhanced.

It might be that IDEA steps in a recompiles them without using Maven, hence bypassing the plugin.

I have decompiled them, they are identical to the original source code so I guess that they are not being enhanced. I’ve tried recompiling with Maven, but it does not make a difference. I’ve checked the console for any printouts, but there doesn’t seem to be anything about the bytecode tool. Any ideas? Should it just be enough to include the tool in the pom-file and then compile using maven? Also I’m running unit tests to test my application.

Check out my GitHub repository.

If you enable enableLazyInitialization and run:

mvn clean test-compile

and go to core/target/classes, you’ll see the entity classes are enhanced.

Also, Maven tells you that it enhances classes when running test-compile.