Permalink
Browse files

HHH-1283 : Join fetched collections using Query.scroll() is correct o…

…nly for first entity
  • Loading branch information...
1 parent 8eb7d8c commit 3a72b45325ce8ac7350cc0c176656dcda3776b36 @gbadner gbadner committed Sep 13, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 hibernate-core/src/main/java/org/hibernate/loader/Loader.java
@@ -395,7 +395,7 @@ private Object sequentialLoad(
}
}
while ( resultSet.next() &&
- keyToRead.equals( getKeyFromResultSet( 0, getEntityPersisters()[0], null, resultSet, session ) ) );
+ isCurrentRowForSameEntity( keyToRead, 0, resultSet, session ) );
}
catch ( SQLException sqle ) {
throw factory.getSQLExceptionHelper().convert(
@@ -415,6 +415,17 @@ private Object sequentialLoad(
return result;
}
+ private boolean isCurrentRowForSameEntity(
+ final EntityKey keyToRead,
+ final int persisterIndex,
+ final ResultSet resultSet,
+ final SessionImplementor session) throws SQLException {
+ EntityKey currentRowKey = getKeyFromResultSet(
+ persisterIndex, getEntityPersisters()[persisterIndex], null, resultSet, session
+ );
+ return keyToRead.equals( currentRowKey );
+ }
+
/**
* Loads a single logical row from the result set moving forward. This is the
* processing used from the ScrollableResults where there were collection fetches

0 comments on commit 3a72b45

Please sign in to comment.