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(); } /**