Skip to content

Commit 40f6ad6

Browse files
dreab8beikov
authored andcommitted
HHH-17964 Hibernate using wrong column order for ElementCollection query when composite ID is present
1 parent 06fe054 commit 40f6ad6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,14 +736,20 @@ private static void bindImplicitColumns(
736736
PersistentClass referencedEntity,
737737
AnnotatedJoinColumns joinColumns,
738738
SimpleValue value) {
739-
final List<Column> idColumns = referencedEntity instanceof JoinedSubclass
740-
? referencedEntity.getKey().getColumns()
741-
: referencedEntity.getIdentifier().getColumns();
739+
final KeyValue keyValue = referencedEntity instanceof JoinedSubclass
740+
? referencedEntity.getKey()
741+
: referencedEntity.getIdentifier();
742+
final List<Column> idColumns = keyValue.getColumns();
742743
for ( Column column: idColumns ) {
743744
final AnnotatedJoinColumn firstColumn = joinColumns.getJoinColumns().get(0);
744745
firstColumn.linkValueUsingDefaultColumnNaming( column, referencedEntity, value);
745746
firstColumn.overrideFromReferencedColumnIfNecessary( column );
746747
}
748+
if ( keyValue instanceof Component
749+
&& ( (Component) keyValue ).isSorted()
750+
&& value instanceof DependantValue ) {
751+
( (DependantValue) value ).setSorted( true );
752+
}
747753
}
748754

749755
private static void bindUnownedAssociation(

0 commit comments

Comments
 (0)