From 4eb27e61b1bd4c074e8e2b87f9ffceb18bc521d6 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 13 Jul 2021 17:56:35 +0200 Subject: [PATCH] Fix StateleSession call to PostLoadEvent causing NPE --- ...cValuesSourceProcessingStateStandardImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java index 54bd383fa2..d2adcc6eda 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java @@ -192,14 +192,16 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo loadingEntityMap.forEach( (entityKey, loadingEntityEntry) -> { - postLoadEvent.reset(); - postLoadEvent.setEntity( loadingEntityEntry.getEntityInstance() ) - .setId( entityKey.getIdentifier() ) - .setPersister( loadingEntityEntry.getDescriptor() ); - - for ( PostLoadEventListener listener : listenerGroup.listeners() ) { - listener.onPostLoad( postLoadEvent ); + if ( postLoadEvent != null ) { + postLoadEvent.reset(); + postLoadEvent.setEntity( loadingEntityEntry.getEntityInstance() ) + .setId( entityKey.getIdentifier() ) + .setPersister( loadingEntityEntry.getDescriptor() ); + for ( PostLoadEventListener listener : listenerGroup.listeners() ) { + listener.onPostLoad( postLoadEvent ); + } } + executionContext.invokeAfterLoadActions( getSession(), loadingEntityEntry.getEntityInstance(),