From c320c6e8dd5adc89dba404957137f2b94abd013d 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 0a2bea94d3..8648ff09df 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -249,6 +249,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 ); @@ -685,7 +686,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 ); }