'Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set / multiple databases

Spring boot application. I have this data source:

package _ourapp_.vTiger

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.jdbc.DataSourceBuilder
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.orm.jpa.JpaTransactionManager
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
import org.springframework.stereotype.Component
import javax.sql.DataSource

@Configuration
@Component("_ourapp_.vTiger")
@EnableJpaRepositories(
    basePackages = ["_ourapp_.vTiger"],
    entityManagerFactoryRef = "vTigerEntityManager",
    transactionManagerRef = "vTigerTransactionManager"
)
open class DataSource {

    @Bean
    @ConfigurationProperties(prefix = "database.vtiger")
    open fun calldata_base(): DataSource = DataSourceBuilder.create().build()

    @Bean
    open fun vTigerEntityManager(): LocalContainerEntityManagerFactoryBean =
        (LocalContainerEntityManagerFactoryBean()).apply {
            dataSource = calldata_base()
            setPackagesToScan("_ourapp_.vTiger.model")
            jpaVendorAdapter = HibernateJpaVendorAdapter()
        }

    @Bean
    open fun vTigerTransactionManager() = JpaTransactionManager(vTigerEntityManager().`object`!!)
}

and in application.properties:

database.vtiger.jdbc-url=jdbc:mariadb://_ourdatabaseinstance_.rds.amazonaws.com:3306
database.vtiger.user=_ourname_
database.vtiger.username=_ourname_
database.vtiger.password=_ourpass_
database.vtiger.maximum-pool-size=5
database.vtiger.driver-class-name=org.mariadb.jdbc.Driver
database.vtiger.database-platform=org.hibernate.dialect.MariaDBDialect
database.vtiger.dialect=org.hibernate.dialect.MariaDBDialect
hibernate.dialect=org.hibernate.dialect.MariaDBDialect

because our application has another database, omitted here for simplicity.

It is connecting to an AWS Aurora instance, engine version 5.6.mysql_aurora.1.22.5

Application startup fails with multiple messages including

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vTigerEntityManager' defined in class path resource [au/com/ngv/kitten/vTiger/DataSource.class]: 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]

(which is why I quoted the particular source above, since vTigerEntityManager is defined therein) but finally the dreaded

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

I'm using MariaDB because the IntelliJ database connection tool recommended it over the MySQL driver.

How can hibernate.dialect be 'not set' when it clearly is set in application.properties?

In case it's relevant, I'm using this workaround in IntelliJ itself. The error occurs when I run the application within IntelliJ.



Solution 1:[1]

This is the right variable to set in application.properties:

spring.jpa.properties.hibernate.dialect 

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 Younes El-karama