Home > Mobile >  Unable to resolve name [org.hibernate.dialect.FirebirdDialect]
Unable to resolve name [org.hibernate.dialect.FirebirdDialect]

Time:12-09

I'm trying to connect my Firebird database in Spring, but I'm not succeeding. This was the most exact setting in application.properties.

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url:jdbc:firebirdsql:localhost/3050:C:/DB/DASHBOARD.FDB
spring.datasource.username:SYSDBA
spring.datasource.password:masterkey
spring.datasource.driver-class-name=org.firebirdsql.jdbc.FBDriver

spring.jpa.show-sql: true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.generate-ddl=true
spring.jpa.database-platform=org.hibernate.dialect.FirebirdDialect
org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name \[org.hibernate.dialect.FirebirdInnoDBDialect\] as strategy \[org.hibernate.dialect.Dialect\]
    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:155) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:237) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:190) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:96) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:59) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:206) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:36) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:119) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:255) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:230) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.model.relational.Database.\<init\>(Database.java:44) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:218) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.\<init\>(InFlightMetadataCollectorImpl.java:191) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:138) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1350) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1421) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:66) \~\[spring-orm-6.0.2.jar:6.0.2\]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) \~\[spring-orm-6.0.2.jar:6.0.2\]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) \~\[spring-orm-6.0.2.jar:6.0.2\]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) \~\[spring-orm-6.0.2.jar:6.0.2\]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) \~\[spring-orm-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) \~\[spring-beans-6.0.2.jar:6.0.2\]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1130) \~\[spring-context-6.0.2.jar:6.0.2\]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:905) \~\[spring-context-6.0.2.jar:6.0.2\]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) \~\[spring-context-6.0.2.jar:6.0.2\]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) \~\[spring-boot-3.0.0.jar:3.0.0\]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) \~\[spring-boot-3.0.0.jar:3.0.0\]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) \~\[spring-boot-3.0.0.jar:3.0.0\]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) \~\[spring-boot-3.0.0.jar:3.0.0\]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) \~\[spring-boot-3.0.0.jar:3.0.0\]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) \~\[spring-boot-3.0.0.jar:3.0.0\]
    at com.aula.restiapi.RestiapiApplication.main(RestiapiApplication.java:10) \~\[classes/:na\]
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class \[org.hibernate.dialect.FirebirdInnoDBDialect\]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:123) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:151) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    ... 39 common frames omitted
Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.dialect.FirebirdInnoDBDialect
    at org.hibernate.boot.registry.classloading.internal.AggregatedClassLoader.findClass(AggregatedClassLoader.java:210) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587) \~\[na:na\]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) \~\[na:na\]
    at java.base/java.lang.Class.forName0(Native Method) \~\[na:na\]
    at java.base/java.lang.Class.forName(Class.java:467) \~\[na:na\]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:120) \~\[hibernate-core-6.1.5.Final.jar:6.1.5.Final\]
    ... 40 common frames omitted

CodePudding user response:

The problem is that you're using Hibernate 6, and in Hibernate 6, the Firebird dialect and a number of other dialects were moved to a separate artifact, org.hibernate.orm:hibernate-community-dialects, and the name was changed to org.hibernate.community.dialect.FirebirdDialect.

So, you need to add the hibernate-community-dialects dependency to your project, and use org.hibernate.community.dialect.FirebirdDialect in the application.properties.

For example, in pom.xml, section dependencies:

<dependency>
  <groupId>org.hibernate.orm</groupId>
  <artifactId>hibernate-community-dialects</artifactId>
</dependency>

Then in application.properties, use:

spring.jpa.database-platform=org.hibernate.community.dialect.FirebirdDialect
  • Related