Is it worth using the Hibernate Bytecode Enhancement mechanism?

I’m currently reading Vlad Mihalcea’s book High-Performance Java Persistence.

In the Bytecode Enhancement section, it is said that enableDirtyTracking can optimize performance with large amounts of data through replacing reflections. But I’m just wondering if there are any disadvantages?

Unfortunately, I couldn’t find any or only very old information.


And while doing further research in the Hibernate documentation I came across three more properties:

  • enableLazyInitialization,
  • enableAssociationManagement,
  • enableExtendedEnhancement.

But I can’t find much about it on the internet.

If I understood it correctly, enableAssociationManagement makes the independent handling of bidirectional relationships superfluous and replaces enableLazyInitialization like enableDirtyTracking Reflections?

Unfortunately, I couldn’t find anything about enableExtendedEnhancement. That’s why I have the same question as above. Should I just use it? Or which disadvantages result from it?


The enableAssociationManagement only works from parent to child entities, not the other way around. So, it’s not very useful. Better synchronize both ends of a bidirectional association using add/remove methods.

The enableLazyInitialization can be useful for lazy attributes, like fetching a parent-side @OneToOne association lazily, as by default, this one is fetched eagerly even when set to FetchType.LAZY.

The enableDirtyTracking setting is not needed if you make sure the Persistence Context never loads too many entities. You are better off reducing the Persistence Context size than using this setting.

The enableExtendedEnhancement setting allow a you to extends more than the entity classes, so bytecode enhancement can work even beyond calling getters and setters on entities. This setting is not recommended.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..