borinquenkid commented on code in PR #16539:
URL: https://github.com/apache/grails-core/pull/16539#discussion_r4225225207


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CompositeIdentifierToManyToOneBinder.java:
##########
@@ -126,7 +127,10 @@ private Optional<Stream<ColumnConfig>> 
tryExpandNestedComposite(
         if (nestedComposite == null) {
             return Optional.empty();
         }
+        // Hibernate sorts the properties of a composite identifier by name, 
and the columns this key
+        // references follow that order, so the foreign key columns are named 
in the same order
         return Optional.of(Arrays.stream(nestedComposite)
+                
.sorted(Comparator.comparing(HibernatePersistentProperty::getName))

Review Comment:
   You're right, the property permutation only fit one-column parts. 
`sortOrIndexForeignKeyColumns` and `getReferencedIdentifierColumns` now move 
each part with its whole column span. Your PrbGrand/PrbMiddle/PrbLeaf case, 
plus a three-column nested part between two plain parts, are in 
`CompositeForeignKeyColumnTypesSpec` with the key-order pairs and a save and 
reload. I also removed the unused `Transactional` import and updated the PR 
description.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to