From 3a72b45325ce8ac7350cc0c176656dcda3776b36 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 13 Sep 2012 12:30:15 -0700 Subject: [PATCH] HHH-1283 : Join fetched collections using Query.scroll() is correct only for first entity --- .../src/main/java/org/hibernate/loader/Loader.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java index debfcfa138..ad7d032307 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java @@ -395,7 +395,7 @@ public abstract class Loader { } } 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 @@ public abstract class Loader { 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