From 2271e18ba57ef02d589be839619e10f7c878b9f0 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Tue, 7 Feb 2023 13:43:41 +0100 Subject: [PATCH] [HHH-16122] Fix determining the type of a property during type variable resolving for mapped superclasses --- .../hibernate/boot/model/internal/ClassPropertyHolder.java | 7 ++++++- .../org/hibernate/boot/model/internal/PropertyBinder.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java index 703efb1876..5be0e8c1d6 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java @@ -269,7 +269,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder { final Value originalValue = prop.getValue(); if ( originalValue instanceof SimpleValue ) { // Avoid copying when the property doesn't depend on a type variable - if ( inferredData.getTypeName().equals( getTypeName( originalValue ) ) ) { + if ( inferredData.getTypeName().equals( getTypeName( prop ) ) ) { superclass.addDeclaredProperty( prop ); return; } @@ -329,6 +329,11 @@ public class ClassPropertyHolder extends AbstractPropertyHolder { } } + static String getTypeName(Property property) { + final String typeName = getTypeName( property.getValue() ); + return typeName != null ? typeName : property.getReturnedClassName(); + } + static String getTypeName(Value value) { if ( value instanceof Component ) { final Component component = (Component) value; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java index 2d418329e5..43bd70b1f6 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java @@ -365,7 +365,7 @@ public class PropertyBinder { final Value originalValue = prop.getValue(); if ( originalValue instanceof SimpleValue ) { // Avoid copying when the property doesn't depend on a type variable - if ( inferredData.getTypeName().equals( ClassPropertyHolder.getTypeName( originalValue ) ) ) { + if ( inferredData.getTypeName().equals( ClassPropertyHolder.getTypeName( prop ) ) ) { superclass.setDeclaredIdentifierProperty( prop ); return; }