HHH-18384 Inheritance hierarchy must be followed

This commit is contained in:
Čedomir Igaly 2024-11-17 14:40:39 +01:00
parent 38da18b3bd
commit 3f6d7a5da7
4 changed files with 12 additions and 13 deletions

View File

@ -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;

View File

@ -634,7 +634,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 );
}

View File

@ -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() ) {

View File

@ -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<PropertyData> elements,
PropertyContainer propertyContainer,
MetadataBuildingContext context) {
int idPropertyCounter = 0;
MetadataBuildingContext context, int idPropertyCounter) {
for ( MemberDetails property : propertyContainer.propertyIterator() ) {
idPropertyCounter = addProperty( propertyContainer, property, elements, context, idPropertyCounter );
}