From a917bb4b40c36dc9e09e11aaba36e160fb91601b Mon Sep 17 00:00:00 2001 From: Andrig Miller Date: Wed, 25 May 2011 17:35:07 -0600 Subject: [PATCH] HHH-6258: Cached JdbcServices and Dialect in local variables to lessen load on AbtractServiceRegistryImpl.localServiceBinding(java.lang.Class). This improved throughput. --- .../org/hibernate/internal/SessionFactoryImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 57f16a315a..ecd579b07d 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -189,6 +189,8 @@ public final class SessionFactoryImpl private final transient Map fetchProfiles; private final transient Map imports; private final transient SessionFactoryServiceRegistry serviceRegistry; + private final transient JdbcServices jdbcServices; + private final transient Dialect dialect; private final transient Settings settings; private final transient Properties properties; private transient SchemaExport schemaExport; @@ -252,6 +254,8 @@ public final class SessionFactoryImpl this, cfg ); + this.jdbcServices = this.serviceRegistry.getService( JdbcServices ); + this.dialect = this.jdbcServices.getDialect(); this.sqlFunctionRegistry = new SQLFunctionRegistry( getDialect(), cfg.getSqlFunctions() ); if ( observer != null ) { this.observer.addObserver( observer ); @@ -965,14 +969,15 @@ public final class SessionFactoryImpl } public JdbcServices getJdbcServices() { - return serviceRegistry.getService( JdbcServices.class ); + return jdbcServices; } public Dialect getDialect() { if ( serviceRegistry == null ) { throw new IllegalStateException( "Cannot determine dialect because serviceRegistry is null." ); } - return getJdbcServices().getDialect(); + return dialect; + //return getJdbcServices().getDialect(); } public Interceptor getInterceptor() @@ -1159,7 +1164,7 @@ public final class SessionFactoryImpl } public ConnectionProvider getConnectionProvider() { - return serviceRegistry.getService( JdbcServices.class ).getConnectionProvider(); + return jdbcServices.getConnectionProvider(); } /**