<div class="sect4">
##### Run-time enhancement
<div class="paragraph">
Currently, run-time enhancement of the domain model is only supported in managed JPA environments following the JPA-defined SPI for performing class transformations.
Even then, this support is disabled by default.
To enable run-time enhancement, specify `hibernate.ejb.use_class_enhancer`=`true` as a persistent unit property.
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
</td>
<td class="content">
<div class="paragraph">
Also, at the moment, only annotated classes are supported for run-time enhancement.
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="sect4">
##### Gradle plugin
<div class="paragraph">
Hibernate provides a Gradle plugin that is capable of providing build-time enhancement of the domain model as they are compiled as part of a Gradle build.
To use the plugin a project would first need to apply it:
</div>
<div class="exampleblock">
<div class="title">Example 226. Apply the Gradle plugin</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight">`ext {
hibernateVersion = 'hibernate-version-you-want'
}
buildscript {
dependencies {
classpath "org.hibernate:hibernate-gradle-plugin:$hibernateVersion"
}
}
hibernate {
enhance {
// any configuration goes here
}
}`</pre>
</div>
</div>
</div>
</div>
<div class="paragraph">
The configuration that is available is exposed through a registered Gradle DSL extension:
</div>
<div class="dlist">
<dl>
<dt class="hdlist1">enableLazyInitialization</dt>
<dd>
Whether enhancement for lazy attribute loading should be done.
</dd>
<dt class="hdlist1">enableDirtyTracking</dt>
<dd>
Whether enhancement for self-dirty tracking should be done.
</dd>
<dt class="hdlist1">enableAssociationManagement</dt>
<dd>
Whether enhancement for bi-directional association management should be done.
</dd>
</dl>
</div>
<div class="paragraph">
The default value for all 3 configuration settings is `true`
</div>
<div class="paragraph">
The `enhance { }` block is required in order for enhancement to occur.
Enhancement is disabled by default in preparation for additions capabilities (hbm2ddl, etc) in the plugin.
</div>
</div>
<div class="sect4">
##### Maven plugin
<div class="paragraph">
Hibernate provides a Maven plugin capable of providing build-time enhancement of the domain model as they are compiled as part of a Maven build.
See the section on the [Gradle plugin](#BytecodeEnhancement-enhancement-gradle) for details on the configuration settings. Again, the default for those 3 is `true`.
</div>
<div class="paragraph">
The Maven plugin supports one additional configuration settings: failOnError, which controls what happens in case of error.
Default behavior is to fail the build, but it can be set so that only a warning is issued.
</div>
<div class="exampleblock">
<div class="title">Example 227. Apply the Maven plugin</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight">`<build>
<plugins>
[...]
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>$currentHibernateVersion</version>
<executions>
<execution>
<configuration>
<failOnError>true</failOnError>
<enableLazyInitialization>true</enableLazyInitialization>
<enableDirtyTracking>true</enableDirtyTracking>
<enableAssociationManagement>true</enableAssociationManagement>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
[...]
</plugins>
</build>`</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect2">