HHH-17382 Walk superclasses when searching instantiation field

This commit is contained in:
Marco Belladelli 2023-11-06 11:30:35 +01:00
parent 56efddc58d
commit 27c30788bd
1 changed files with 4 additions and 1 deletions

View File

@ -95,7 +95,7 @@ public class DynamicInstantiationAssemblerInjectionImpl<T> implements DomainResu
private Field findField(Class<?> declaringClass, String name, Class<?> javaType) {
try {
Field field = declaringClass.getDeclaredField( name );
final Field field = declaringClass.getDeclaredField( name );
// field should never be null
if ( Compatibility.areAssignmentCompatible( field.getType(), javaType ) ) {
field.setAccessible( true );
@ -103,6 +103,9 @@ public class DynamicInstantiationAssemblerInjectionImpl<T> implements DomainResu
}
}
catch (NoSuchFieldException ignore) {
if ( declaringClass.getSuperclass() != null ) {
return findField( declaringClass.getSuperclass(), name, javaType );
}
}
return null;