HHH-4688 Make sure @OrderBy works for @ElementCollection. Handle default case

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18419 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Scott Marlow 2010-01-06 16:59:34 +00:00
parent bd6a77a0dc
commit 71d9459a20
1 changed files with 2 additions and 1 deletions

View File

@ -1243,7 +1243,8 @@ public abstract class CollectionBinder {
element.setFetchMode( FetchMode.JOIN );
element.setLazy( false );
element.setIgnoreNotFound( ignoreNotFound );
if ( StringHelper.isNotEmpty( hqlOrderBy ) ) {
// as per 11.1.38 of JPA-2 spec, default to primary key if no column is specified by @OrderBy.
if ( hqlOrderBy != null ) {
collValue.setManyToManyOrdering(
buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() )
);