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

I am getting exception even after setting hibernate.dialect property. I am using hibernate 5.0.11 with spring boot 1.4.2 and mysql version as 5.7

application.properties is like this

# Hibernate
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=validate

pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

What is issue here ?



Solution 1:[1]

Adding the following line to the properties file solve this problem when I had that error.

spring.jpa.database=mysql

Solution 2:[2]

I also just had a similar issue, but realized I hadn't customized the DB name field properly from copy and pasting into the application.properties file created from Springboot's tutorial:

spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword

Be sure to replace db_example springuser and ThePassword with your actual values.

Just a "duh" moment for myself, but may be of some use to others.

Solution 3:[3]

Probably you already solved this, but I had a similar issue.

Adding explicit runtime dependency to mysql should solve the problem:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

That allows spring boot to auto-configure jdbc related beans based on classpath.

Solution 4:[4]

adding the following after creating the Configuration solve the problem :

configuration.configure("hibernate.cfg.xml");

Solution 5:[5]

I was blatantly missing:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

Also this post has some helpful tips: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

Solution 6:[6]

In my case, I started my spring boot application with the database excluded:

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class})

Then once I started creating JPA classes I got an error which I tried to fix with:

@Bean(name = "entityManagerFactory")
public LocalSessionFactoryBean sessionFactory() {
    return new LocalSessionFactoryBean();
}

This led to the exception mentioned in the question.

So the solution was simply to remove DataSourceAutoConfiguration.class from the @SpringBootApplication annotation of course, but it took some time before I noticed the error.

Solution 7:[7]

I faced the same issue with my Spring boot project upon connecting to an Oracle database.

These are the following steps I performed to troubleshoot-

  1. Make sure relevant hibernate properties are present in application.properties file hibernate.dialect=org.hibernate.dialect.Oracle12cDialect,

    spring.jpa.hibernate.ddl-auto=update

    the dialect depends on which datbase you are using. Also the hibernate.ddl-auto can be one of the 5 properties.

  2. Verify the JDBC url. For e.g. connection string for oracle is like jdbc:oracle:thin:@10.10.32.20:1521/SRV_LICENSING_D1

  3. Verify the database credentials.

  4. Make sure the service name used is in upper case in your property file. Because hibernate is case sensitive. For e.g. service name in case of oracle would be something like SRV_LICENSING_D1

Solution 8:[8]

Reason: Database connection is not satisfied while dialects for db, which database is not important.

Solution: Correct connection string in application.properties (or where is it)

Solution 9:[9]

In my case the problem was the access modifier to my custom DialectResolver. It was not public.. Rookie mistake :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 riorio
Solution 2 NateH06
Solution 3
Solution 4 hsusanoo
Solution 5 Ian Newland
Solution 6 JavaDevOps
Solution 7 Caffeine Coder
Solution 8 Hamit YILDIRIM
Solution 9 Piotr Niewinski