borinquenkid commented on code in PR #16539:
URL: https://github.com/apache/grails-core/pull/16539#discussion_r4223901954
##########
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:
Yes, I'll fix it in this PR. Thanks for the reproduction and the sketch.
I'll add your PrbGrand/PrbMiddle/PrbLeaf case as a Hibernate-backed spec in
`CompositeForeignKeyColumnTypesSpec`, with the `KEY_SEQ` assertion plus a save
and reload. The fix applies the permutation across each part's column span in
both `sortOrIndexForeignKeyColumns` and `getReferencedIdentifierColumns`. I'll
also remove the unused `Transactional` import and update the 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]