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

Here this issue occurred while connecting to database through Hibernate and not declared dialect while mentioning all connection properties. In hibernate dialect is required properties so that hibernate known what type of queries need to generate because every database have different queries patterns.

Exception Stacktrace


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) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:94) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.3.10.Final.jar:5.3.10.Final]

Solutions

Below is example to connect to H2 database by hibernate. You can update properties values according to your database. Added hibernate.dialect to connect H2 database.

Hibernate Supported Dialect List

In hibernate.cfg.xml

<property name="dialect">
org.hibernate.dialect.H2Dialect
</property>

In application.properties with Spring boot + JPA

spring.jpa.database-platform=org.hibernate.dialect

References

https://stackoverflow.com/questions/24655684/spring-boot-default-h2-jdbc-connection-and-h2-console