HHH-10076 - bytecode enhancer - CompositeEnhancer does not add ManagedComposite marker interface
(cherry picked from commit 4d6eca5ff8
)
This commit is contained in:
parent
ae6d84b974
commit
e3c6c02178
|
@ -28,6 +28,9 @@ public class CompositeEnhancer extends Enhancer {
|
|||
}
|
||||
|
||||
public void enhance(CtClass managedCtClass) {
|
||||
// add the ManagedComposite interface
|
||||
managedCtClass.addInterface( managedCompositeCtClass );
|
||||
|
||||
addInterceptorHandling( managedCtClass );
|
||||
|
||||
if ( enhancementContext.doDirtyCheckingInline( managedCtClass ) ) {
|
||||
|
|
|
@ -42,6 +42,7 @@ public class Enhancer {
|
|||
|
||||
protected final ClassPool classPool;
|
||||
protected final CtClass managedEntityCtClass;
|
||||
protected final CtClass managedCompositeCtClass;
|
||||
protected final CtClass attributeInterceptorCtClass;
|
||||
protected final CtClass attributeInterceptableCtClass;
|
||||
protected final CtClass entityEntryCtClass;
|
||||
|
@ -57,16 +58,11 @@ public class Enhancer {
|
|||
this.enhancementContext = enhancementContext;
|
||||
this.classPool = buildClassPool( enhancementContext );
|
||||
|
||||
// add ManagedEntity contract
|
||||
// pre-load some of the interfaces that are used
|
||||
this.managedEntityCtClass = loadCtClassFromClass( classPool, ManagedEntity.class );
|
||||
|
||||
// add PersistentAttributeInterceptable contract
|
||||
this.managedCompositeCtClass = loadCtClassFromClass( classPool, ManagedComposite.class );
|
||||
this.attributeInterceptableCtClass = loadCtClassFromClass( classPool, PersistentAttributeInterceptable.class );
|
||||
|
||||
// add PersistentAttributeInterceptor contract
|
||||
this.attributeInterceptorCtClass = loadCtClassFromClass( classPool, PersistentAttributeInterceptor.class );
|
||||
|
||||
// add PersistentAttributeInterceptor contract
|
||||
this.entityEntryCtClass = loadCtClassFromClass( classPool, EntityEntry.class );
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
@ -125,7 +121,7 @@ public class Enhancer {
|
|||
private void enhance(CtClass managedCtClass) {
|
||||
// can't effectively enhance interfaces
|
||||
if ( managedCtClass.isInterface() ) {
|
||||
log.debugf( "Skipping enhancement of [%s]: it's an interface", managedCtClass );
|
||||
log.debugf( "Skipping enhancement of [%s]: it's an interface!", managedCtClass.getName() );
|
||||
return;
|
||||
}
|
||||
// skip already enhanced classes
|
||||
|
@ -149,7 +145,7 @@ public class Enhancer {
|
|||
new PersistentAttributesEnhancer( enhancementContext ).enhanceFieldAccess( managedCtClass );
|
||||
}
|
||||
else {
|
||||
log.debug( "Skipping enhancement: not entity or composite" );
|
||||
log.debugf( "Skipping enhancement of [%s]: not entity or composite", managedCtClass.getName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.property.access.internal;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.bytecode.enhance.spi.EnhancerConstants;
|
||||
import org.hibernate.engine.spi.Managed;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.property.access.spi.BuiltInPropertyAccessStrategies;
|
||||
import org.hibernate.property.access.spi.PropertyAccessStrategy;
|
||||
|
@ -36,7 +34,7 @@ public class PropertyAccessStrategyResolverStandardImpl implements PropertyAcces
|
|||
String explicitAccessStrategyName,
|
||||
EntityMode entityMode) {
|
||||
|
||||
if ( hasBytecodeEnhancedAttributes( containerClass ) ) {
|
||||
if ( Managed.class.isAssignableFrom( containerClass ) ) {
|
||||
return PropertyAccessStrategyEnhancedImpl.INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -75,14 +73,4 @@ public class PropertyAccessStrategyResolverStandardImpl implements PropertyAcces
|
|||
return strategySelectorService;
|
||||
}
|
||||
|
||||
private boolean hasBytecodeEnhancedAttributes(Class<?> containerClass) {
|
||||
for ( Method m : containerClass.getDeclaredMethods() ) {
|
||||
if ( m.getName().startsWith( EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX ) ||
|
||||
m.getName().startsWith( EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue