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.
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>${hibernate.version}</version>
<executions>
<execution>
<configuration>
<failOnError>true</failOnError>
<enableDirtyTracking>true</enableDirtyTracking>
<enableLazyInitialization>false</enableLazyInitialization>
<enableAssociationManagement>false</enableAssociationManagement>
<enableExtendedEnhancement>false</enableExtendedEnhancement>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With