diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/InlineDirtyCheckerEqualsHelper.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/InlineDirtyCheckerEqualsHelper.java index 8be0d9087218..098db0b8051a 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/InlineDirtyCheckerEqualsHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/InlineDirtyCheckerEqualsHelper.java @@ -20,7 +20,7 @@ public static boolean areEquals( Object b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return Objects.deepEquals( a, b ); @@ -33,7 +33,7 @@ public static boolean areEquals( boolean b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; @@ -46,7 +46,7 @@ public static boolean areEquals( byte b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; @@ -59,7 +59,7 @@ public static boolean areEquals( short b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; @@ -72,7 +72,7 @@ public static boolean areEquals( char b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; @@ -85,7 +85,7 @@ public static boolean areEquals( int b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; @@ -98,7 +98,7 @@ public static boolean areEquals( long b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; @@ -111,7 +111,7 @@ public static boolean areEquals( float b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; @@ -124,7 +124,7 @@ public static boolean areEquals( double b) { final PersistentAttributeInterceptor persistentAttributeInterceptor = persistentAttributeInterceptable.$$_hibernate_getInterceptor(); if ( persistentAttributeInterceptor != null - && !persistentAttributeInterceptor.getInitializedLazyAttributeNames().contains( fieldName ) ) { + && !persistentAttributeInterceptor.isAttributeLoaded( fieldName ) ) { return false; } return a == b; diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/BytecodeLazyAttributeInterceptor.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/BytecodeLazyAttributeInterceptor.java index a4fd9a7593e0..5ff6b950c8c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/BytecodeLazyAttributeInterceptor.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/BytecodeLazyAttributeInterceptor.java @@ -36,6 +36,7 @@ public interface BytecodeLazyAttributeInterceptor extends SessionAssociableInter */ void attributeInitialized(String name); + @Override boolean isAttributeLoaded(String fieldName); boolean hasAnyUninitializedAttributes(); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/PersistentAttributeInterceptor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/PersistentAttributeInterceptor.java index 61e80eca6da2..c984e4ce520b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/PersistentAttributeInterceptor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/PersistentAttributeInterceptor.java @@ -78,4 +78,19 @@ default Set getInitializedLazyAttributeNames() { @Deprecated default void attributeInitialized(String name) { } + + /** + * + * Callback from the enhanced class that an attribute has been loaded + * + * @deprecated Interceptors that deal with + * * lazy state should implement {@link BytecodeLazyAttributeInterceptor} + * + * @param fieldName + * @return true id the attribute is loaded false otherwise + */ + @Deprecated + default boolean isAttributeLoaded(String fieldName){ + return false; + } }