Skip to content

Commit b6b4507

Browse files
committed
HHH-19660 - Deprecate enhancement support for automatic association management
Signed-off-by: Jan Schatteman <[email protected]>
1 parent c0cb619 commit b6b4507

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

documentation/src/main/asciidoc/userguide/chapters/pc/BytecodeEnhancement.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ include::{example-dir-enhancement}/BytecodeEnhancementTest.java[tags=BytecodeEnh
9595

9696
Bytecode-enhanced bi-directional association management makes that first example work by managing the "other side" of a bi-directional association whenever one side is manipulated.
9797

98+
[IMPORTANT]
99+
Bytecode-enhanced bi-directional association management has been deprecated as of Hibernate v7.1, and will be removed in a future release. Users are encouraged to move away from this functionality and instead adopt
100+
correct Java usage as outlined in the <<BytecodeEnhancement-dirty-tracking-bidirectional-correct-usage-example, example>> above.
101+
98102
[[BytecodeEnhancement-dirty-tracking-optimizations]]
99103
==== Internal performance optimizations
100104

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/EnhancementContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public interface EnhancementContext {
6868
* @return {@code true} indicates that the field is enhanced so that for bi-directional persistent fields
6969
* the association is managed, i.e. the associations are automatically set; {@code false} indicates that
7070
* the management is handled by the user.
71+
* @deprecated Will be removed without replacement. See HHH-19660
7172
*/
73+
@Deprecated(forRemoval = true)
7274
boolean doBiDirectionalAssociationManagement(UnloadedField field);
7375

7476
/**

tooling/hibernate-ant/src/main/java/org/hibernate/tool/enhance/EnhancementTask.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.List;
3333

3434
import static org.hibernate.bytecode.internal.BytecodeProviderInitiator.buildDefaultBytecodeProvider;
35+
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
3536

3637
/**
3738
* Ant task for performing build-time enhancement of entity objects.
@@ -203,6 +204,10 @@ public boolean doExtendedEnhancement(UnloadedClass classDescriptor) {
203204
log( "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.", Project.MSG_WARN );
204205
}
205206

207+
if ( enableAssociationManagement ) {
208+
DEPRECATION_LOGGER.deprecatedSettingForRemoval( "management of bi-directional association persistent attributes", "false" );
209+
}
210+
206211
final BytecodeProvider bytecodeProvider = buildDefaultBytecodeProvider();
207212
try {
208213
Enhancer enhancer = bytecodeProvider.getEnhancer( enhancementContext );

tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/enhance/EnhancementHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public static void enhance(
4747
if ( !enhancementDsl.getEnableLazyInitialization().get() ) {
4848
logger.warn( "The 'enableLazyInitialization' configuration is deprecated and will be removed. Set the value to 'true' to get rid of this warning" );
4949
}
50+
if ( enhancementDsl.getEnableAssociationManagement().get() ) {
51+
logger.warn("Management of bi-directional association persistent attributes is deprecated and will be removed. Set the value to 'false' to get rid of this warning" );
52+
}
5053
if ( !enhancementDsl.getEnableDirtyTracking().get() ) {
5154
logger.warn( "The 'enableDirtyTracking' configuration is deprecated and will be removed. Set the value to 'true' to get rid of this warning" );
5255
}

tooling/hibernate-maven-plugin/src/main/java/org/hibernate/orm/tooling/maven/EnhancementContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
99
import org.hibernate.bytecode.enhance.spi.UnloadedField;
1010

11+
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
12+
1113
public class EnhancementContext extends DefaultEnhancementContext {
1214

1315
private ClassLoader classLoader = null;
@@ -36,6 +38,9 @@ public ClassLoader getLoadingClassLoader() {
3638

3739
@Override
3840
public boolean doBiDirectionalAssociationManagement(UnloadedField field) {
41+
if ( enableAssociationManagement ) {
42+
DEPRECATION_LOGGER.deprecatedSettingForRemoval( "management of bi-directional persistent association attributes", "false" );
43+
}
3944
return enableAssociationManagement;
4045
}
4146

0 commit comments

Comments
 (0)