HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set

As part of upgrade from Hibernate 3 to 5.1.15, we are using the following session factory configuration for database test.

< bean id="hibernateSessionFactory" class="com.company.hibernate.CustomHibernateSessionFactoryBean">
< property name="hibernateProperties">
            < value>
                **hibernate.dialect=org.hibernate.dialect.MariaDBDialect**
				hibernate.id.new_generator_mappings=true
                hibernate.cache.use_second_level_cache=false
                hibernate.cache.use_query_cache=false
                hibernate.cache.region.factory_class=org.hibernate.cache.infinispan.InfinispanRegionFactory
            < /value>
        < /property>
        < property name="packagesToScan" value="com.netapp.dfm.entity"/>
        < property name="dataSource" ref="dataSource"/>
    < /bean>
Caused by:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

Caused by:
org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

Caused by:
**org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set**

I am not sure why hibernate.dialect is not set in the map(configValues).
dialect

It could be because you are using a custom HibernateSessionFactoryBean and you are not propagating the Hibernate properties as they should:

com.company.hibernate.CustomHibernateSessionFactoryBean

Same configuration was working earlier in hibernate 3.

Instead of
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
hibernate.cache.region.factory_class=org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
I am using the below in in hibernate 5
hibernate.cache.region.factory_class=org.hibernate.cache.infinispan.InfinispanRegionFactory

I was expecting it to be smooth transition, however looks like it isn’t.
Is there any specific change which i have to incorporate with newer hibernate ?
Any bean initialization i have to make to get it working ?

Extending framework classes is risky. You need to check why it was working in Hibernate 3 and it’s not working now.

I was expecting it to be smooth transition, however looks like it isn’t.

Did you follow all Migration Guides?

Is there any specific change which i have to incorporate with newer hibernate ?

The Migration Guides capture all these changes.

Any bean initialization i have to make to get it working ?

If you use the Spring version that was meant to work with the Hibernate 5 version you want to migrate to, then you will have no issue. Just use the HibernateSessionFactoryBean from Spring.

ConnectionProviderInitiator class initiateService() method has a map configurationValues which is not having hibernate.connection.url
I was expecting setting hibernateProperties in CustomHibernateSessionFactoryBean would set the configurationValues.

I will debug and keep you posted on this.

Not able to figure out why it is not working.
I am using Spring 3 and hibernate 5.1.15 and using annotation for datasource configuration.

I am not able to relate how, where, when JdbcEnvironment is registered in normal code and why it it not registered in dbtest

Attaching complete log for more information.

com.company.project.webui.package.SampleDbTest > testAggregationSummary STANDARD_OUT
    2019-01-28 22:49:41,437 INFO  [Test worker] [c.n.d.p.p.DatabasePlatform] Using database jdbc:mysql://localhost:3306/product?cachePrepStmts=true&prepStmtCacheSize=1000&prepStmtCacheSqlLimit=1000
    2019-01-28 22:49:42,234 INFO  [Test worker] [c.n.d.p.h.projectHibernateSessionFactoryBean] Overriding inventory schema name to mock_sample_view
    2019-01-28 22:49:42,271 WARN  [Test worker] [o.h.e.j.c.i.ConnectionProviderInitiator] HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
    2019-01-28 22:49:42,273 WARN  [Test worker] [o.h.e.j.e.i.JdbcEnvironmentInitiator] HHH000342: Could not obtain connection to query metadata : The application must supply JDBC connections
    2019-01-28 22:49:42,275 WARN  [Test worker] [o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityDeleter': Unsatisfied dependency expressed through field 'session'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hibernateSessionProxyFactoryBean': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
    2019-01-28 22:49:42,278 ERROR [Test worker] [o.s.t.c.TestContextManager] Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@6c004124] to prepare test instance [com.company.project.webui.package.SampleDbTest@37b459ad]
    java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:122)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:284)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
        at com.company.project.da.test.DatabaseTestSupport$SpringStyleTestRunner.runChild(DatabaseTestSupport.java:162)
        at com.company.project.da.test.DatabaseTestSupport$SpringStyleTestRunner.runChild(DatabaseTestSupport.java:147)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy3.processTestClass(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:108)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityDeleter': Unsatisfied dependency expressed through field 'session'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hibernateSessionProxyFactoryBean': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:592)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:370)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
        at com.company.project.common.test.spring.AnnotationConfigContextLoader.loadContext(AnnotationConfigContextLoader.java:60)
        at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:70)
        at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91)
        ... 49 common frames omitted
    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hibernateSessionProxyFactoryBean': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:592)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:370)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
        ... 64 common frames omitted
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:589)
        ... 77 common frames omitted
    Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
        at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
        at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
        at com.company.project.persist.hibernate.projectHibernateSessionFactoryBean.buildSessionFactory(projectHibernateSessionFactoryBean.java:108)
        at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:495)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
        ... 87 common frames omitted
    Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100)
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137)
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254)
        ... 102 common frames omitted
Gradle Test Executor 1 finished executing tests.

com.company.project.webui.package.SampleDbTest > testAggregationSummary FAILED
    java.lang.IllegalStateException: Failed to load ApplicationContext

        Caused by:
        org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityDeleter': Unsatisfied dependency expressed through field 'session'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hibernateSessionProxyFactoryBean': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

            Caused by:
            org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hibernateSessionProxyFactoryBean': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

                Caused by:
                org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in class path resource [spring/database-test-support.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

                    Caused by:
                    org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

                        Caused by:
                        org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

1 test completed, 1 failed

@Override
public MetadataSources getMetadataSources() {
    this.metadataSourcesAccessed = true;
    if (this.metadataSources == null) {
        BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
        ResourcePatternResolver resourcePatternResolver = (ResourcePatternResolver) getResourceLoader();
        if (resourcePatternResolver != null) {
            builder = builder.applyClassLoader(resourcePatternResolver.getClassLoader()).applyIntegrator(eventListenerIntegrator);
        }
        this.metadataSources = new MetadataSources(builder.build());
    }
    return this.metadataSources;
}

@Override
protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) {

    if (!DatabasePlatform.INVENTORY_SCHEMA.equals(DatabasePlatform.DEFAULT_INVENTORY_SCHEMA)) {
        logger.info("Overriding inventory schema name to %s", DatabasePlatform.INVENTORY_SCHEMA);
        Metadata metadata = getMetadataSources().getMetadataBuilder().build();
        Collection<PersistentClass> entityBindings = metadata.getEntityBindings();
		/* do customization */
        
    }
    return (this.bootstrapExecutor != null ? sfb.buildSessionFactory(this.bootstrapExecutor) : sfb.buildSessionFactory());

}

Please guide me if need to code it in different way

Spring already offers a way to bootstrap Hibernate via the LocalSessionFactoryBean. Why don’t you use that instead?

I tried it but still getting same error.

<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
		<property name="hibernateProperties">
			<value>
				hibernate.id.new_generator_mappings=true
				hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
				hibernate.cache.use_second_level_cache=true
				hibernate.cache.use_query_cache=false
				hibernate.generate_statistics=false
				hibernate.cache.use_structured_entries=true
				hibernate.connection.datasource=java:/onaro_pool
			</value>
		</property>
		<property name="packagesToScan" value="com.company.entity" />
		<property name="dataSource" ref="dataSource" />
	</bean>

Maybe you should ask the question on the Spring forum since this issue seems to be related to Spring, not Hibernate.

It would be a Hibernate issue only if you can replicate with this test case which does not depend on Spring.

We have not modified spring, it is just hibernate upgrade.
Earlier also we were using same spring(4.3.4). and same spring classes.

I believe it is something related to Hibernate service registry, like how it is configured. or something related to its lifecycle. Do i need to inject some new hibernate class ?

Try to replicate it with a test case so we can also take a look at it.

Hi @sandeep_kamath @vlad

I am facing similar issue .
Spring tests fail with hibernate dialect not set even when dialect set with jpa.hibernate.

Application runs fine and able to make connection.

Can you provide some solutions ?