HHH-17964 Hibernate using wrong column order for ElementCollection query when composite ID is present

This commit is contained in:
Andrea Boriero 2024-04-24 14:01:40 +02:00 committed by Christian Beikov
parent 06fe05482c
commit 40f6ad6700
1 changed files with 9 additions and 3 deletions

View File

@ -736,14 +736,20 @@ public class TableBinder {
PersistentClass referencedEntity,
AnnotatedJoinColumns joinColumns,
SimpleValue value) {
final List<Column> idColumns = referencedEntity instanceof JoinedSubclass
? referencedEntity.getKey().getColumns()
: referencedEntity.getIdentifier().getColumns();
final KeyValue keyValue = referencedEntity instanceof JoinedSubclass
? referencedEntity.getKey()
: referencedEntity.getIdentifier();
final List<Column> idColumns = keyValue.getColumns();
for ( Column column: idColumns ) {
final AnnotatedJoinColumn firstColumn = joinColumns.getJoinColumns().get(0);
firstColumn.linkValueUsingDefaultColumnNaming( column, referencedEntity, value);
firstColumn.overrideFromReferencedColumnIfNecessary( column );
}
if ( keyValue instanceof Component
&& ( (Component) keyValue ).isSorted()
&& value instanceof DependantValue ) {
( (DependantValue) value ).setSorted( true );
}
}
private static void bindUnownedAssociation(