HHH-10359 - Change default values in bytecode enhance build-time plugins
This commit is contained in:
parent
f0ad6dabd5
commit
f16b8aafdf
|
@ -83,7 +83,7 @@ Currently the "enhance" extension supports 4 properties:
|
|||
* `enableLazyInitialization`
|
||||
* `enableDirtyTracking`
|
||||
* `enableAssociationManagement`
|
||||
* `enableFieldAccessEnhancement`
|
||||
* `enableExtendedEnhancement`
|
||||
|
||||
Once enhancement overall is enabled, the default for the first 3 properties is `true`. Field access is not enhanced by
|
||||
default, as it can potentially trigger enhancement of code outside the entities, and also because it assumes that all
|
||||
|
@ -102,7 +102,7 @@ on the plugin are:
|
|||
* `enableLazyInitialization`
|
||||
* `enableDirtyTracking`
|
||||
* `enableAssociationManagement`
|
||||
* `enableFieldAccessEnhancement`
|
||||
* `enableExtendedEnhancement`
|
||||
|
||||
Field access is not enhanced by default, because it can potentially trigger enhancement of code outside the entities.
|
||||
Other capabilities are enabled by default. Even if the plugin is enabled, the bytecode enhancement can be bypassed by
|
||||
|
@ -133,7 +133,7 @@ already in use. The XML snippet below is an example of how to declare and config
|
|||
<enableLazyInitialization>true</enableLazyInitialization>
|
||||
<enableDirtyTracking>true</enableDirtyTracking>
|
||||
<enableAssociationManagement>true</enableAssociationManagement>
|
||||
<enableFieldAccessEnhancement>false</enableFieldAccessEnhancement>
|
||||
<enableExtendedEnhancement>false</enableExtendedEnhancement>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>enhance</goal>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
|
||||
<persistence-unit name="Example">
|
||||
[...]
|
||||
<properties>
|
||||
[...]
|
||||
<property name="hibernate.enhancer.enableLazyInitialization" value="false"/>
|
||||
<property name="hibernate.enhancer.enableDirtyTracking" value="false"/>
|
||||
<property name="hibernate.enhancer.enableAssociationManagement" value="false"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
|
@ -56,22 +56,22 @@ public class MavenEnhancePlugin extends AbstractMojo {
|
|||
private List<File> sourceSet = new ArrayList<File>();
|
||||
|
||||
@Parameter(property = "dir", defaultValue = "${project.build.outputDirectory}")
|
||||
private String dir = null;
|
||||
private String dir;
|
||||
|
||||
@Parameter(property = "failOnError", defaultValue = "true")
|
||||
private boolean failOnError = true;
|
||||
|
||||
@Parameter(property = "enableLazyInitialization", defaultValue = "true")
|
||||
private boolean enableLazyInitialization = true;
|
||||
@Parameter(property = "enableLazyInitialization", defaultValue = "false")
|
||||
private boolean enableLazyInitialization;
|
||||
|
||||
@Parameter(property = "enableDirtyTracking", defaultValue = "true")
|
||||
private boolean enableDirtyTracking = true;
|
||||
@Parameter(property = "enableDirtyTracking", defaultValue = "false")
|
||||
private boolean enableDirtyTracking;
|
||||
|
||||
@Parameter(property = "enableAssociationManagement", defaultValue = "true")
|
||||
private boolean enableAssociationManagement = true;
|
||||
@Parameter(property = "enableAssociationManagement", defaultValue = "false")
|
||||
private boolean enableAssociationManagement;
|
||||
|
||||
@Parameter(property = "enableExtendedEnhancement", defaultValue = "false")
|
||||
private boolean enableExtendedEnhancement = false;
|
||||
private boolean enableExtendedEnhancement;
|
||||
|
||||
private boolean shouldApply() {
|
||||
return enableLazyInitialization || enableDirtyTracking || enableAssociationManagement || enableExtendedEnhancement;
|
||||
|
@ -79,7 +79,7 @@ public class MavenEnhancePlugin extends AbstractMojo {
|
|||
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
if ( !shouldApply() ) {
|
||||
getLog().info( "Skipping Hibernate enhancement plugin execution since there is no feature enabled" );
|
||||
getLog().warn( "Skipping Hibernate bytecode enhancement plugin execution since no feature is enabled" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<description>Enable enhancement for management of bi-direction associations</description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>enableFieldAccessEnhancement</name>
|
||||
<name>enableExtendedEnhancement</name>
|
||||
<type>java.lang.Boolean</type>
|
||||
<required>false</required>
|
||||
<editable>true</editable>
|
||||
|
@ -77,10 +77,10 @@
|
|||
<configuration>
|
||||
<dir>${project.build.outputDirectory}</dir>
|
||||
<failOnError>true</failOnError>
|
||||
<enableLazyInitialization>true</enableLazyInitialization>
|
||||
<enableDirtyTracking>true</enableDirtyTracking>
|
||||
<enableAssociationManagement>true</enableAssociationManagement>
|
||||
<enableFieldAccessEnhancement>false</enableFieldAccessEnhancement>
|
||||
<enableLazyInitialization>false</enableLazyInitialization>
|
||||
<enableDirtyTracking>false</enableDirtyTracking>
|
||||
<enableAssociationManagement>false</enableAssociationManagement>
|
||||
<enableExtendedEnhancement>false</enableExtendedEnhancement>
|
||||
</configuration>
|
||||
</mojo>
|
||||
</mojos>
|
||||
|
|
|
@ -79,9 +79,10 @@
|
|||
<configuration>
|
||||
<dir>${project.build.outputDirectory}</dir>
|
||||
<failOnError>true</failOnError>
|
||||
<enableLazyInitialization>true</enableLazyInitialization>
|
||||
<enableDirtyTracking>true</enableDirtyTracking>
|
||||
<enableAssociationManagement>true</enableAssociationManagement>
|
||||
<enableLazyInitialization>false</enableLazyInitialization>
|
||||
<enableDirtyTracking>false</enableDirtyTracking>
|
||||
<enableAssociationManagement>false</enableAssociationManagement>
|
||||
<enableExtendedEnhancement>false</enableExtendedEnhancement>
|
||||
</configuration>
|
||||
</mojo>
|
||||
</mojos>
|
||||
|
|
|
@ -13,12 +13,12 @@ package org.hibernate.orm.tooling.gradle
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
class EnhanceExtension {
|
||||
def boolean enableLazyInitialization = true
|
||||
def boolean enableDirtyTracking = true
|
||||
def boolean enableAssociationManagement = true
|
||||
def boolean enableFieldAccessEnhancement = false
|
||||
def boolean enableLazyInitialization = false
|
||||
def boolean enableDirtyTracking = false
|
||||
def boolean enableAssociationManagement = false
|
||||
def boolean enableExtendedEnhancement = false
|
||||
|
||||
boolean shouldApply() {
|
||||
return enableLazyInitialization || enableDirtyTracking || enableAssociationManagement || enableFieldAccessEnhancement;
|
||||
return enableLazyInitialization || enableDirtyTracking || enableAssociationManagement || enableExtendedEnhancement;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public class HibernatePlugin implements Plugin<Project> {
|
|||
|
||||
private void applyEnhancement(final Project project, final HibernateExtension hibernateExtension) {
|
||||
if ( !hibernateExtension.enhance.shouldApply() ) {
|
||||
project.getLogger().warn( "Skipping Hibernate bytecode enhancement since no feature is enabled" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,11 +113,11 @@ public class HibernatePlugin implements Plugin<Project> {
|
|||
|
||||
@Override
|
||||
public boolean doExtendedEnhancement(CtClass classDescriptor) {
|
||||
return hibernateExtension.enhance.getEnableFieldAccessEnhancement();
|
||||
return hibernateExtension.enhance.getEnableExtendedEnhancement();
|
||||
}
|
||||
};
|
||||
|
||||
if ( hibernateExtension.enhance.getEnableFieldAccessEnhancement() ) {
|
||||
if ( hibernateExtension.enhance.getEnableExtendedEnhancement() ) {
|
||||
logger.warn( "Extended enhancement is enabled. Classes other than entities may be modified. You should consider access the entities using getter/setter methods and disable this property. Use at your own risk." );
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class HibernatePluginTest {
|
|||
enableLazyInitialization = true
|
||||
enableDirtyTracking = true
|
||||
enableAssociationManagement = false
|
||||
enableFieldAccessEnhancement = false
|
||||
enableExtendedEnhancement = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue