From 234bff41b8b6041be8911e526b267403ff730419 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Wed, 31 Jul 2024 10:16:08 +0200 Subject: [PATCH] HHH-18445 Always preserve correct property order for java records --- .../org/hibernate/boot/model/internal/PropertyContainer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java index e90f5a014e..bd763ed533 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java @@ -139,8 +139,8 @@ public class PropertyContainer { List getters) { final Map attributeMemberMap; // If the record class has only record components which match up with fields and no additional getters, - // we can retain the property order, to match up with the record component order - if ( !recordComponents.isEmpty() && recordComponents.size() == fields.size() && getters.isEmpty() ) { + // we must retain the property order, to match up with the record component order + if ( !recordComponents.isEmpty() && recordComponents.size() == fields.size() ) { attributeMemberMap = new LinkedHashMap<>(); } //otherwise we sort them in alphabetical order, since this is at least deterministic