From f5696f9f67dd81d0b966b9b8d9abce9fb328b006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Cedomir=20Igaly?= Date: Sun, 17 Nov 2024 14:40:39 +0100 Subject: [PATCH] HHH-18384 Inheritance hierarchy must be followed --- .../hibernate/boot/model/internal/EmbeddableBinder.java | 8 ++++---- .../org/hibernate/boot/model/internal/EntityBinder.java | 2 +- .../hibernate/boot/model/internal/InheritanceState.java | 7 +++---- .../org/hibernate/boot/model/internal/PropertyBinder.java | 8 ++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java index dd26cf9238..0b0f9384c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java @@ -648,7 +648,7 @@ public class EmbeddableBinder { //embeddable elements can have type defs final PropertyContainer container = new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor ); - addElementsOfClass( classElements, container, context); + addElementsOfClass( classElements, container, context, 0 ); //add elements of the embeddable's mapped superclasses ClassDetails subclass = returnedClassOrElement; ClassDetails superClass; @@ -659,7 +659,7 @@ public class EmbeddableBinder { annotatedClass, propertyAccessor ); - addElementsOfClass( classElements, superContainer, context ); + addElementsOfClass( classElements, superContainer, context, 0 ); if ( subclassToSuperclass != null ) { subclassToSuperclass.put( subclass.getName(), superClass.getName() ); } @@ -690,7 +690,7 @@ public class EmbeddableBinder { assert put == null; // collect property of subclass final PropertyContainer superContainer = new PropertyContainer( subclass, superclass, propertyAccessor ); - addElementsOfClass( classElements, superContainer, context ); + addElementsOfClass( classElements, superContainer, context, 0 ); // recursively do that same for all subclasses collectSubclassElements( propertyAccessor, @@ -764,7 +764,7 @@ public class EmbeddableBinder { entityAtStake, propertyAccessor ); - addElementsOfClass( baseClassElements, container, context ); + addElementsOfClass( baseClassElements, container, context, 0 ); baseReturnedClassOrElement = baseReturnedClassOrElement.determineRawClass().getGenericSuperType(); } return baseClassElements; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java index afe23915b7..c2a3226c7e 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java @@ -633,7 +633,7 @@ public class EntityBinder { inferredData.getPropertyType(), propertyAccessor ); - addElementsOfClass( baseClassElements, propContainer, context ); + addElementsOfClass( baseClassElements, propContainer, context, 0 ); //Id properties are on top and there is only one return baseClassElements.get( 0 ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java index d9830b5a86..c149b68062 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java @@ -235,12 +235,11 @@ public class InheritanceState { classDetails, accessType ); - int currentIdPropertyCount = addElementsOfClass( + idPropertyCount = addElementsOfClass( elements, propertyContainer, - buildingContext - ); - idPropertyCount += currentIdPropertyCount; + buildingContext, + idPropertyCount ); } if ( idPropertyCount == 0 && !inheritanceState.hasParents() ) { 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 d8a096f13b..668cbca1c4 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 @@ -583,15 +583,15 @@ public class PropertyBinder { /** * @param elements List of {@link PropertyData} instances * @param propertyContainer Metadata about a class and its properties + * @param idPropertyCounter number of id properties already present in list of {@link PropertyData} instances * - * @return the number of id properties found while iterating the elements of - * {@code annotatedClass} using the determined access strategy + * @return total number of id properties found after iterating the elements of + * {@code annotatedClass} using the determined access strategy */ static int addElementsOfClass( List elements, PropertyContainer propertyContainer, - MetadataBuildingContext context) { - int idPropertyCounter = 0; + MetadataBuildingContext context, int idPropertyCounter) { for ( MemberDetails property : propertyContainer.propertyIterator() ) { idPropertyCounter = addProperty( propertyContainer, property, elements, context, idPropertyCounter ); }