HHH-13496 Keyset iteration optimisations on Session opening properties
This commit is contained in:
parent
9c19bbd611
commit
3d69df1ebf
|
@ -609,10 +609,10 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
@Override
|
@Override
|
||||||
public Session createEntityManager() {
|
public Session createEntityManager() {
|
||||||
validateNotClosed();
|
validateNotClosed();
|
||||||
return buildEntityManager( SynchronizationType.SYNCHRONIZED, Collections.emptyMap() );
|
return buildEntityManager( SynchronizationType.SYNCHRONIZED, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Session buildEntityManager(SynchronizationType synchronizationType, Map map) {
|
private <K,V> Session buildEntityManager(final SynchronizationType synchronizationType, final Map<K,V> map) {
|
||||||
assert !isClosed;
|
assert !isClosed;
|
||||||
|
|
||||||
SessionBuilderImplementor builder = withOptions();
|
SessionBuilderImplementor builder = withOptions();
|
||||||
|
@ -625,11 +625,13 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
|
|
||||||
final Session session = builder.openSession();
|
final Session session = builder.openSession();
|
||||||
if ( map != null ) {
|
if ( map != null ) {
|
||||||
map.keySet().forEach( key -> {
|
for ( Map.Entry<K, V> o : map.entrySet() ) {
|
||||||
|
final K key = o.getKey();
|
||||||
if ( key instanceof String ) {
|
if ( key instanceof String ) {
|
||||||
session.setProperty( (String) key, map.get( key ) );
|
final String sKey = (String) key;
|
||||||
|
session.setProperty( sKey, o.getValue() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
@ -644,7 +646,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
public Session createEntityManager(SynchronizationType synchronizationType) {
|
public Session createEntityManager(SynchronizationType synchronizationType) {
|
||||||
validateNotClosed();
|
validateNotClosed();
|
||||||
errorIfResourceLocalDueToExplicitSynchronizationType();
|
errorIfResourceLocalDueToExplicitSynchronizationType();
|
||||||
return buildEntityManager( synchronizationType, Collections.emptyMap() );
|
return buildEntityManager( synchronizationType, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void errorIfResourceLocalDueToExplicitSynchronizationType() {
|
private void errorIfResourceLocalDueToExplicitSynchronizationType() {
|
||||||
|
|
Loading…
Reference in New Issue