Skip to content

Commit f5696f9

Browse files
cigalymbellade
authored andcommitted
HHH-18384 Inheritance hierarchy must be followed
1 parent d3f5b98 commit f5696f9

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ private static List<PropertyData> collectClassElements(
648648
//embeddable elements can have type defs
649649
final PropertyContainer container =
650650
new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor );
651-
addElementsOfClass( classElements, container, context);
651+
addElementsOfClass( classElements, container, context, 0 );
652652
//add elements of the embeddable's mapped superclasses
653653
ClassDetails subclass = returnedClassOrElement;
654654
ClassDetails superClass;
@@ -659,7 +659,7 @@ private static List<PropertyData> collectClassElements(
659659
annotatedClass,
660660
propertyAccessor
661661
);
662-
addElementsOfClass( classElements, superContainer, context );
662+
addElementsOfClass( classElements, superContainer, context, 0 );
663663
if ( subclassToSuperclass != null ) {
664664
subclassToSuperclass.put( subclass.getName(), superClass.getName() );
665665
}
@@ -690,7 +690,7 @@ private static void collectSubclassElements(
690690
assert put == null;
691691
// collect property of subclass
692692
final PropertyContainer superContainer = new PropertyContainer( subclass, superclass, propertyAccessor );
693-
addElementsOfClass( classElements, superContainer, context );
693+
addElementsOfClass( classElements, superContainer, context, 0 );
694694
// recursively do that same for all subclasses
695695
collectSubclassElements(
696696
propertyAccessor,
@@ -764,7 +764,7 @@ private static List<PropertyData> collectBaseClassElements(
764764
entityAtStake,
765765
propertyAccessor
766766
);
767-
addElementsOfClass( baseClassElements, container, context );
767+
addElementsOfClass( baseClassElements, container, context, 0 );
768768
baseReturnedClassOrElement = baseReturnedClassOrElement.determineRawClass().getGenericSuperType();
769769
}
770770
return baseClassElements;

hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ private static PropertyData getUniqueIdPropertyFromBaseClass(
633633
inferredData.getPropertyType(),
634634
propertyAccessor
635635
);
636-
addElementsOfClass( baseClassElements, propContainer, context );
636+
addElementsOfClass( baseClassElements, propContainer, context, 0 );
637637
//Id properties are on top and there is only one
638638
return baseClassElements.get( 0 );
639639
}

hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,11 @@ private ElementsToProcess getElementsToProcess() {
235235
classDetails,
236236
accessType
237237
);
238-
int currentIdPropertyCount = addElementsOfClass(
238+
idPropertyCount = addElementsOfClass(
239239
elements,
240240
propertyContainer,
241-
buildingContext
242-
);
243-
idPropertyCount += currentIdPropertyCount;
241+
buildingContext,
242+
idPropertyCount );
244243
}
245244

246245
if ( idPropertyCount == 0 && !inheritanceState.hasParents() ) {

hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,15 +583,15 @@ private void validateOptimisticLock(boolean excluded) {
583583
/**
584584
* @param elements List of {@link PropertyData} instances
585585
* @param propertyContainer Metadata about a class and its properties
586+
* @param idPropertyCounter number of id properties already present in list of {@link PropertyData} instances
586587
*
587-
* @return the number of id properties found while iterating the elements of
588-
* {@code annotatedClass} using the determined access strategy
588+
* @return total number of id properties found after iterating the elements of
589+
* {@code annotatedClass} using the determined access strategy
589590
*/
590591
static int addElementsOfClass(
591592
List<PropertyData> elements,
592593
PropertyContainer propertyContainer,
593-
MetadataBuildingContext context) {
594-
int idPropertyCounter = 0;
594+
MetadataBuildingContext context, int idPropertyCounter) {
595595
for ( MemberDetails property : propertyContainer.propertyIterator() ) {
596596
idPropertyCounter = addProperty( propertyContainer, property, elements, context, idPropertyCounter );
597597
}

0 commit comments

Comments
 (0)