HHH-15505 Fix bytecode enhancement on entity whose field is defined both in mapped superclass and concrete entity
This commit is contained in:
parent
b0e74d4638
commit
e8d089a993
|
@ -91,6 +91,12 @@ final class PersistentAttributeTransformer implements AsmVisitorWrapper.ForDecla
|
|||
ByteBuddyEnhancementContext enhancementContext,
|
||||
TypePool classPool) {
|
||||
List<AnnotatedFieldDescription> persistentFieldList = new ArrayList<>();
|
||||
// HHH-10646 Add fields inherited from @MappedSuperclass
|
||||
// HHH-10981 There is no need to do it for @MappedSuperclass
|
||||
// HHH-15505 This needs to be done first so that fields with the same name in the mappedsuperclass and entity are handled correctly
|
||||
if ( !enhancementContext.isMappedSuperclassClass( managedCtClass ) ) {
|
||||
persistentFieldList.addAll( collectInheritPersistentFields( managedCtClass, enhancementContext ) );
|
||||
}
|
||||
for ( FieldDescription ctField : managedCtClass.getDeclaredFields() ) {
|
||||
// skip static fields and skip fields added by enhancement and outer reference in inner classes
|
||||
if ( ctField.getName().startsWith( "$$_hibernate_" ) || "this$0".equals( ctField.getName() ) ) {
|
||||
|
@ -101,11 +107,6 @@ final class PersistentAttributeTransformer implements AsmVisitorWrapper.ForDecla
|
|||
persistentFieldList.add( annotatedField );
|
||||
}
|
||||
}
|
||||
// HHH-10646 Add fields inherited from @MappedSuperclass
|
||||
// HHH-10981 There is no need to do it for @MappedSuperclass
|
||||
if ( !enhancementContext.isMappedSuperclassClass( managedCtClass ) ) {
|
||||
persistentFieldList.addAll( collectInheritPersistentFields( managedCtClass, enhancementContext ) );
|
||||
}
|
||||
|
||||
AnnotatedFieldDescription[] orderedFields = enhancementContext.order( persistentFieldList.toArray( new AnnotatedFieldDescription[0] ) );
|
||||
if ( log.isDebugEnabled() ) {
|
||||
|
|
Loading…
Reference in New Issue