diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java index 26438774c945..16ffdd83eb22 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java @@ -743,9 +743,10 @@ private static void bindImplicitColumns( PersistentClass referencedEntity, AnnotatedJoinColumns joinColumns, SimpleValue value) { - final List idColumns = referencedEntity instanceof JoinedSubclass - ? referencedEntity.getKey().getColumns() - : referencedEntity.getIdentifier().getColumns(); + final KeyValue keyValue = referencedEntity instanceof JoinedSubclass + ? referencedEntity.getKey() + : referencedEntity.getIdentifier(); + final List idColumns = keyValue.getColumns(); for ( int i = 0; i < idColumns.size(); i++ ) { final Column column = idColumns.get(i); final AnnotatedJoinColumn firstColumn = joinColumns.getJoinColumns().get(0); @@ -767,6 +768,11 @@ private static void bindImplicitColumns( } } } + if ( keyValue instanceof Component + && ( (Component) keyValue ).isSorted() + && value instanceof DependantValue ) { + ( (DependantValue) value ).setSorted( true ); + } } private static void bindUnownedAssociation(