Skip to content

Commit

Permalink
HHH-18384 Preserving order of @id annotated elements while adding to …
Browse files Browse the repository at this point in the history
…list before other elements
  • Loading branch information
cigaly committed Nov 17, 2024
1 parent 83dbfdc commit 38da18b
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ static int addElementsOfClass(
MetadataBuildingContext context) {
int idPropertyCounter = 0;
for ( MemberDetails property : propertyContainer.propertyIterator() ) {
idPropertyCounter += addProperty( propertyContainer, property, elements, context );
idPropertyCounter = addProperty( propertyContainer, property, elements, context, idPropertyCounter );
}
return idPropertyCounter;
}
Expand All @@ -602,20 +602,19 @@ private static int addProperty(
PropertyContainer propertyContainer,
MemberDetails property,
List<PropertyData> inFlightPropertyDataList,
MetadataBuildingContext context) {
MetadataBuildingContext context, int idPropertyCounter) {
// see if inFlightPropertyDataList already contains a PropertyData for this name,
// and if so, skip it...
for ( PropertyData propertyData : inFlightPropertyDataList ) {
if ( propertyData.getPropertyName().equals( property.resolveAttributeName() ) ) {
checkIdProperty( property, propertyData );
// EARLY EXIT!!!
return 0;
return idPropertyCounter;
}
}

final ClassDetails declaringClass = propertyContainer.getDeclaringClass();
final TypeVariableScope ownerType = propertyContainer.getTypeAtStake();
int idPropertyCounter = 0;
final PropertyData propertyAnnotatedElement = new PropertyInferredData(
declaringClass,
ownerType,
Expand All @@ -628,7 +627,7 @@ private static int addProperty(
// before any association by Hibernate
final MemberDetails element = propertyAnnotatedElement.getAttributeMember();
if ( hasIdAnnotation( element ) ) {
inFlightPropertyDataList.add( 0, propertyAnnotatedElement );
inFlightPropertyDataList.add( idPropertyCounter, propertyAnnotatedElement );
handleIdProperty( propertyContainer, context, declaringClass, ownerType, element );
if ( hasToOneAnnotation( element ) ) {
context.getMetadataCollector()
Expand Down

0 comments on commit 38da18b

Please # to comment.