From 3d69df1ebfa158df631f77e9edf0e3967c4789eb Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Fri, 5 Jul 2019 19:23:38 +0100 Subject: [PATCH] HHH-13496 Keyset iteration optimisations on Session opening properties --- .../org/hibernate/internal/SessionFactoryImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index 0d15a94be4..2bca556cf7 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -609,10 +609,10 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { @Override public Session createEntityManager() { validateNotClosed(); - return buildEntityManager( SynchronizationType.SYNCHRONIZED, Collections.emptyMap() ); + return buildEntityManager( SynchronizationType.SYNCHRONIZED, null ); } - private Session buildEntityManager(SynchronizationType synchronizationType, Map map) { + private Session buildEntityManager(final SynchronizationType synchronizationType, final Map map) { assert !isClosed; SessionBuilderImplementor builder = withOptions(); @@ -625,11 +625,13 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { final Session session = builder.openSession(); if ( map != null ) { - map.keySet().forEach( key -> { + for ( Map.Entry o : map.entrySet() ) { + final K key = o.getKey(); if ( key instanceof String ) { - session.setProperty( (String) key, map.get( key ) ); + final String sKey = (String) key; + session.setProperty( sKey, o.getValue() ); } - } ); + } } return session; } @@ -644,7 +646,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { public Session createEntityManager(SynchronizationType synchronizationType) { validateNotClosed(); errorIfResourceLocalDueToExplicitSynchronizationType(); - return buildEntityManager( synchronizationType, Collections.emptyMap() ); + return buildEntityManager( synchronizationType, null ); } private void errorIfResourceLocalDueToExplicitSynchronizationType() {