HHH-17526 Throw correct exception when reading list results

This commit is contained in:
Marco Belladelli 2023-12-15 10:50:42 +01:00 committed by Christian Beikov
parent ea90b86f9f
commit 84726a5772
1 changed files with 5 additions and 10 deletions

View File

@ -152,10 +152,9 @@ public class ListResultsConsumer<R> implements ResultsConsumer<List<R>, R> {
final TypeConfiguration typeConfiguration = session.getTypeConfiguration();
final QueryOptions queryOptions = rowProcessingState.getQueryOptions();
RuntimeException ex = null;
try {
persistenceContext.beforeLoad();
persistenceContext.getLoadContexts().register( jdbcValuesSourceProcessingState );
try {
final JavaType<R> domainResultJavaType = resolveDomainResultJavaType(
rowReader.getDomainResultResultJavaType(),
rowReader.getResultJavaTypes(),
@ -207,13 +206,8 @@ public class ListResultsConsumer<R> implements ResultsConsumer<List<R>, R> {
}
}
try {
rowReader.finishUp( jdbcValuesSourceProcessingState );
jdbcValuesSourceProcessingState.finishUp( readRows > 1 );
}
finally {
persistenceContext.getLoadContexts().deregister( jdbcValuesSourceProcessingState );
}
//noinspection unchecked
final ResultListTransformer<R> resultListTransformer =
@ -231,6 +225,7 @@ public class ListResultsConsumer<R> implements ResultsConsumer<List<R>, R> {
try {
jdbcValues.finishUp( session );
persistenceContext.afterLoad();
persistenceContext.getLoadContexts().deregister( jdbcValuesSourceProcessingState );
persistenceContext.initializeNonLazyCollections();
}
catch (RuntimeException e) {