From 33f02f411f71f75ff78fe476ea836048709bf400 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Thu, 20 Jun 2019 10:33:45 +0100 Subject: [PATCH] HHH-13447 Minimize number of EventListenerRegistry lookups within a Session use --- .../src/main/java/org/hibernate/internal/SessionImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 16189e6278..244379182b 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -242,6 +242,7 @@ public final class SessionImpl private transient boolean discardOnClose; private transient TransactionObserver transactionObserver; + private transient EventListenerRegistry eventListenerRegistry; public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { super( factory, options ); @@ -678,7 +679,10 @@ public final class SessionImpl } private EventListenerGroup eventListenerGroup(EventType type) { - return getFactory().getServiceRegistry().getService( EventListenerRegistry.class ).getEventListenerGroup( type ); + if ( this.eventListenerRegistry == null ) { + this.eventListenerRegistry = getFactory().getServiceRegistry().getService( EventListenerRegistry.class ); + } + return eventListenerRegistry.getEventListenerGroup( type ); }