diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/CodeTemplates.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/CodeTemplates.java index 72308feb28..166c3ca277 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/CodeTemplates.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/CodeTemplates.java @@ -608,20 +608,20 @@ class CodeTemplates { static class GetterMapping implements Advice.OffsetMapping { private final TypeDescription.Generic returnType; - private final String name; + private final FieldDescription persistentField; GetterMapping(FieldDescription persistentField) { this( persistentField, persistentField.getType() ); } GetterMapping(FieldDescription persistentField, TypeDescription.Generic returnType) { - this.name = persistentField.getName(); + this.persistentField = persistentField; this.returnType = returnType; } @Override public Target resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Advice.ArgumentHandler argumentHandler, Sort sort) { - MethodDescription.Token signature = new MethodDescription.Token( EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + name , Opcodes.ACC_PUBLIC, returnType ); - MethodDescription method = new MethodDescription.Latent( instrumentedType.getSuperClass().asErasure(), signature ); + MethodDescription.Token signature = new MethodDescription.Token( EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + persistentField.getName() , Opcodes.ACC_PUBLIC, returnType ); + MethodDescription method = new MethodDescription.Latent( persistentField.getDeclaringType().asErasure(), signature ); return new Target.AbstractReadOnlyAdapter() { @Override