Skip to content

Commit 24f6221

Browse files
cigalymbellade
authored andcommitted
HHH-18384 Preserving order of @id annotated elements while adding to list before other elements
1 parent 099a635 commit 24f6221

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static int addElementsOfClass(
565565
MetadataBuildingContext context) {
566566
int idPropertyCounter = 0;
567567
for ( XProperty property : propertyContainer.propertyIterator() ) {
568-
idPropertyCounter += addProperty( propertyContainer, property, elements, context );
568+
idPropertyCounter = addProperty( propertyContainer, property, elements, context, idPropertyCounter );
569569
}
570570
return idPropertyCounter;
571571
}
@@ -574,20 +574,19 @@ private static int addProperty(
574574
PropertyContainer propertyContainer,
575575
XProperty property,
576576
List<PropertyData> inFlightPropertyDataList,
577-
MetadataBuildingContext context) {
577+
MetadataBuildingContext context, int idPropertyCounter) {
578578
// see if inFlightPropertyDataList already contains a PropertyData for this name,
579579
// and if so, skip it..
580580
for ( PropertyData propertyData : inFlightPropertyDataList ) {
581581
if ( propertyData.getPropertyName().equals( property.getName() ) ) {
582582
checkIdProperty( property, propertyData );
583583
// EARLY EXIT!!!
584-
return 0;
584+
return idPropertyCounter;
585585
}
586586
}
587587

588588
final XClass declaringClass = propertyContainer.getDeclaringClass();
589589
final XClass entity = propertyContainer.getEntityAtStake();
590-
int idPropertyCounter = 0;
591590
final PropertyData propertyAnnotatedElement = new PropertyInferredData(
592591
declaringClass,
593592
property,

0 commit comments

Comments
 (0)