From 27c30788bdc5a1dd036f8abefb5f38a42431960c Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Mon, 6 Nov 2023 11:30:35 +0100 Subject: [PATCH] HHH-17382 Walk superclasses when searching instantiation field --- .../internal/DynamicInstantiationAssemblerInjectionImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerInjectionImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerInjectionImpl.java index c289576859..8df680784c 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerInjectionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerInjectionImpl.java @@ -95,7 +95,7 @@ public class DynamicInstantiationAssemblerInjectionImpl 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 implements DomainResu } } catch (NoSuchFieldException ignore) { + if ( declaringClass.getSuperclass() != null ) { + return findField( declaringClass.getSuperclass(), name, javaType ); + } } return null;