diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java index b90df85214..c6b9c7b4cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java @@ -34,10 +34,6 @@ public interface ExecutionContext { Callback getCallback(); - default void invokeAfterLoadActions(SharedSessionContractImplementor session, Object entity, Loadable persister) { - // No-op because by default there is no callback - } - default String getQueryIdentifier(String sql) { return null; } 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 3dd774a2e7..f641cc83eb 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 @@ -21,6 +21,7 @@ import org.hibernate.event.spi.PostLoadEvent; import org.hibernate.event.spi.PostLoadEventListener; import org.hibernate.event.spi.PreLoadEvent; import org.hibernate.persister.entity.Loadable; +import org.hibernate.sql.exec.spi.Callback; import org.hibernate.sql.results.graph.Initializer; import org.hibernate.sql.results.graph.collection.internal.ArrayInitializer; import org.hibernate.query.spi.QueryOptions; @@ -190,16 +191,17 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo postLoadEvent.setEntity( loadingEntityEntry.getEntityInstance() ) .setId( entityKey.getIdentifier() ) .setPersister( loadingEntityEntry.getDescriptor() ); - for ( PostLoadEventListener listener : listenerGroup.listeners() ) { - listener.onPostLoad( postLoadEvent ); - } + listenerGroup.fireEventOnEachListener( postLoadEvent, PostLoadEventListener::onPostLoad ); } - executionContext.invokeAfterLoadActions( - getSession(), - loadingEntityEntry.getEntityInstance(), - (Loadable) loadingEntityEntry.getDescriptor() - ); + final Callback callback = executionContext.getCallback(); + if ( callback != null ) { + callback.invokeAfterLoadActions( + getSession(), + loadingEntityEntry.getEntityInstance(), + (Loadable) loadingEntityEntry.getDescriptor() + ); + } } ); loadingEntityMap = null;