Fix ScrollableResultsImpl not initializing non lazy collections

This commit is contained in:
Andrea Boriero 2021-07-14 16:38:46 +02:00
parent ba5d90d116
commit 3aa875b037
3 changed files with 22 additions and 17 deletions

View File

@ -127,6 +127,11 @@ public class ScrollableResultsImpl<R> extends AbstractScrollableResults<R> {
getProcessingOptions()
);
getRowProcessingState().finishRowProcessing();
getJdbcValuesSourceProcessingState().finishUp();
getRowProcessingState().getSession().getPersistenceContext().initializeNonLazyCollections();
afterScrollOperation();
}

View File

@ -16,9 +16,7 @@ import org.hibernate.engine.spi.CollectionKey;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.service.spi.EventListenerGroup;
import org.hibernate.event.service.spi.EventListenerRegistry;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.EventType;
import org.hibernate.event.spi.PostLoadEvent;
import org.hibernate.event.spi.PostLoadEventListener;
import org.hibernate.event.spi.PreLoadEvent;
@ -164,7 +162,6 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
@Override
public void finishUp() {
try {
// for arrays, we should end the collection load beforeQuery resolving the entities, since the
// actual array instances are not instantiated during loading
finishLoadingArrays();
@ -177,10 +174,6 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
postLoad();
}
finally {
executionContext.getSession().getPersistenceContext().getLoadContexts().deregister( this );
}
}
private void postLoad() {
if ( loadingEntityMap == null ) {
@ -209,6 +202,7 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
);
}
);
loadingEntityMap = null;
}
private void finishLoadingArrays() {
@ -247,7 +241,7 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
loadingCollectionEntry.finishLoading( getExecutionContext() );
}
loadingCollectionMap.clear();
loadingCollectionMap = null;
}
}

View File

@ -114,7 +114,13 @@ public class ListResultsConsumer<R> implements ResultsConsumer<List<R>, R> {
rowProcessingState.finishRowProcessing();
}
}
try {
jdbcValuesSourceProcessingState.finishUp();
}
finally {
persistenceContext.getLoadContexts().deregister( jdbcValuesSourceProcessingState );
}
return results;
}
finally {