Skip to content

Commit 34a3ada

Browse files
cigalymbellade
authored andcommitted
HHH-18384 Inheritance hierarchy must be followed
1 parent 11119a7 commit 34a3ada

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
@@ -629,15 +629,15 @@ private static List<PropertyData> collectClassElements(
629629
//embeddable elements can have type defs
630630
final PropertyContainer container =
631631
new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor );
632-
addElementsOfClass( classElements, container, context);
632+
addElementsOfClass( classElements, container, context, 0 );
633633
//add elements of the embeddable's mapped superclasses
634634
XClass subclass = returnedClassOrElement;
635635
XClass superClass;
636636
while ( isValidSuperclass( superClass = subclass.getSuperclass(), isIdClass ) ) {
637637
//FIXME: proper support of type variables incl var resolved at upper levels
638638
final PropertyContainer superContainer =
639639
new PropertyContainer( superClass, annotatedClass, propertyAccessor );
640-
addElementsOfClass( classElements, superContainer, context );
640+
addElementsOfClass( classElements, superContainer, context, 0 );
641641
if ( subclassToSuperclass != null ) {
642642
subclassToSuperclass.put( subclass.getName(), superClass.getName() );
643643
}
@@ -668,7 +668,7 @@ private static void collectSubclassElements(
668668
assert put == null;
669669
// collect property of subclass
670670
final PropertyContainer superContainer = new PropertyContainer( subclass, superclass, propertyAccessor );
671-
addElementsOfClass( classElements, superContainer, context );
671+
addElementsOfClass( classElements, superContainer, context, 0 );
672672
// recursively do that same for all subclasses
673673
collectSubclassElements(
674674
propertyAccessor,
@@ -739,7 +739,7 @@ private static List<PropertyData> collectBaseClassElements(
739739
while ( !Object.class.getName().equals( baseReturnedClassOrElement.getName() ) ) {
740740
final PropertyContainer container =
741741
new PropertyContainer( baseReturnedClassOrElement, annotatedClass, propertyAccessor );
742-
addElementsOfClass( baseClassElements, container, context );
742+
addElementsOfClass( baseClassElements, container, context, 0 );
743743
baseReturnedClassOrElement = baseReturnedClassOrElement.getSuperclass();
744744
}
745745
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
@@ -617,7 +617,7 @@ private static PropertyData getUniqueIdPropertyFromBaseClass(
617617
inferredData.getPropertyClass(),
618618
propertyAccessor
619619
);
620-
addElementsOfClass( baseClassElements, propContainer, context );
620+
addElementsOfClass( baseClassElements, propContainer, context, 0 );
621621
//Id properties are on top and there is only one
622622
return baseClassElements.get( 0 );
623623
}

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
@@ -234,12 +234,11 @@ private ElementsToProcess getElementsToProcess() {
234234
clazz,
235235
accessType
236236
);
237-
int currentIdPropertyCount = addElementsOfClass(
237+
idPropertyCount = addElementsOfClass(
238238
elements,
239239
propertyContainer,
240-
buildingContext
241-
);
242-
idPropertyCount += currentIdPropertyCount;
240+
buildingContext,
241+
idPropertyCount );
243242
}
244243

245244
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
@@ -555,15 +555,15 @@ private void validateOptimisticLock(OptimisticLock optimisticLock) {
555555
/**
556556
* @param elements List of {@link PropertyData} instances
557557
* @param propertyContainer Metadata about a class and its properties
558+
* @param idPropertyCounter number of id properties already present in list of {@link PropertyData} instances
558559
*
559-
* @return the number of id properties found while iterating the elements of
560-
* {@code annotatedClass} using the determined access strategy
560+
* @return total number of id properties found after iterating the elements of
561+
* {@code annotatedClass} using the determined access strategy
561562
*/
562563
static int addElementsOfClass(
563564
List<PropertyData> elements,
564565
PropertyContainer propertyContainer,
565-
MetadataBuildingContext context) {
566-
int idPropertyCounter = 0;
566+
MetadataBuildingContext context, int idPropertyCounter) {
567567
for ( XProperty property : propertyContainer.propertyIterator() ) {
568568
idPropertyCounter += addProperty( propertyContainer, property, elements, context, idPropertyCounter );
569569
}

0 commit comments

Comments
 (0)