Skip to content

Commit 2811aad

Browse files
dreab8beikov
authored andcommitted
HHH-17964 Hibernate using wrong column order for ElementCollection query when composite ID is present
1 parent 2b4ec1f commit 2811aad

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,10 @@ private static void bindImplicitColumns(
743743
PersistentClass referencedEntity,
744744
AnnotatedJoinColumns joinColumns,
745745
SimpleValue value) {
746-
final List<Column> idColumns = referencedEntity instanceof JoinedSubclass
747-
? referencedEntity.getKey().getColumns()
748-
: referencedEntity.getIdentifier().getColumns();
746+
final KeyValue keyValue = referencedEntity instanceof JoinedSubclass
747+
? referencedEntity.getKey()
748+
: referencedEntity.getIdentifier();
749+
final List<Column> idColumns = keyValue.getColumns();
749750
for ( int i = 0; i < idColumns.size(); i++ ) {
750751
final Column column = idColumns.get(i);
751752
final AnnotatedJoinColumn firstColumn = joinColumns.getJoinColumns().get(0);
@@ -767,6 +768,11 @@ private static void bindImplicitColumns(
767768
}
768769
}
769770
}
771+
if ( keyValue instanceof Component
772+
&& ( (Component) keyValue ).isSorted()
773+
&& value instanceof DependantValue ) {
774+
( (DependantValue) value ).setSorted( true );
775+
}
770776
}
771777

772778
private static void bindUnownedAssociation(

0 commit comments

Comments
 (0)