HHH-18384 Inheritance hierarchy must be followed

This commit is contained in:
Čedomir Igaly 2024-11-17 14:40:39 +01:00 committed by Marco Belladelli
parent d3f5b98249
commit f5696f9f67
4 changed files with 12 additions and 13 deletions

View File

@ -648,7 +648,7 @@ public class EmbeddableBinder {
//embeddable elements can have type defs //embeddable elements can have type defs
final PropertyContainer container = final PropertyContainer container =
new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor ); new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor );
addElementsOfClass( classElements, container, context); addElementsOfClass( classElements, container, context, 0 );
//add elements of the embeddable's mapped superclasses //add elements of the embeddable's mapped superclasses
ClassDetails subclass = returnedClassOrElement; ClassDetails subclass = returnedClassOrElement;
ClassDetails superClass; ClassDetails superClass;
@ -659,7 +659,7 @@ public class EmbeddableBinder {
annotatedClass, annotatedClass,
propertyAccessor propertyAccessor
); );
addElementsOfClass( classElements, superContainer, context ); addElementsOfClass( classElements, superContainer, context, 0 );
if ( subclassToSuperclass != null ) { if ( subclassToSuperclass != null ) {
subclassToSuperclass.put( subclass.getName(), superClass.getName() ); subclassToSuperclass.put( subclass.getName(), superClass.getName() );
} }
@ -690,7 +690,7 @@ public class EmbeddableBinder {
assert put == null; assert put == null;
// collect property of subclass // collect property of subclass
final PropertyContainer superContainer = new PropertyContainer( subclass, superclass, propertyAccessor ); final PropertyContainer superContainer = new PropertyContainer( subclass, superclass, propertyAccessor );
addElementsOfClass( classElements, superContainer, context ); addElementsOfClass( classElements, superContainer, context, 0 );
// recursively do that same for all subclasses // recursively do that same for all subclasses
collectSubclassElements( collectSubclassElements(
propertyAccessor, propertyAccessor,
@ -764,7 +764,7 @@ public class EmbeddableBinder {
entityAtStake, entityAtStake,
propertyAccessor propertyAccessor
); );
addElementsOfClass( baseClassElements, container, context ); addElementsOfClass( baseClassElements, container, context, 0 );
baseReturnedClassOrElement = baseReturnedClassOrElement.determineRawClass().getGenericSuperType(); baseReturnedClassOrElement = baseReturnedClassOrElement.determineRawClass().getGenericSuperType();
} }
return baseClassElements; return baseClassElements;

View File

@ -633,7 +633,7 @@ public class EntityBinder {
inferredData.getPropertyType(), inferredData.getPropertyType(),
propertyAccessor propertyAccessor
); );
addElementsOfClass( baseClassElements, propContainer, context ); addElementsOfClass( baseClassElements, propContainer, context, 0 );
//Id properties are on top and there is only one //Id properties are on top and there is only one
return baseClassElements.get( 0 ); return baseClassElements.get( 0 );
} }

View File

@ -235,12 +235,11 @@ public class InheritanceState {
classDetails, classDetails,
accessType accessType
); );
int currentIdPropertyCount = addElementsOfClass( idPropertyCount = addElementsOfClass(
elements, elements,
propertyContainer, propertyContainer,
buildingContext buildingContext,
); idPropertyCount );
idPropertyCount += currentIdPropertyCount;
} }
if ( idPropertyCount == 0 && !inheritanceState.hasParents() ) { if ( idPropertyCount == 0 && !inheritanceState.hasParents() ) {

View File

@ -583,15 +583,15 @@ public class PropertyBinder {
/** /**
* @param elements List of {@link PropertyData} instances * @param elements List of {@link PropertyData} instances
* @param propertyContainer Metadata about a class and its properties * @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 * @return total number of id properties found after iterating the elements of
* {@code annotatedClass} using the determined access strategy * {@code annotatedClass} using the determined access strategy
*/ */
static int addElementsOfClass( static int addElementsOfClass(
List<PropertyData> elements, List<PropertyData> elements,
PropertyContainer propertyContainer, PropertyContainer propertyContainer,
MetadataBuildingContext context) { MetadataBuildingContext context, int idPropertyCounter) {
int idPropertyCounter = 0;
for ( MemberDetails property : propertyContainer.propertyIterator() ) { for ( MemberDetails property : propertyContainer.propertyIterator() ) {
idPropertyCounter = addProperty( propertyContainer, property, elements, context, idPropertyCounter ); idPropertyCounter = addProperty( propertyContainer, property, elements, context, idPropertyCounter );
} }