Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating bean with name 'entityManagerFactory' : org/hibernate/dialect/PostgreSQL82Dialect

I'm migrating the spring boot parent version from 2.5.12 to 3.0.6 and I faced many issues that I could fix but I struggle with this one :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: org/hibernate/dialect/PostgreSQL82Dialect


Caused by: java.lang.NoClassDefFoundError: org/hibernate/dialect/PostgreSQL82Dialect
    at com.vladmihalcea.hibernate.type.HibernateTypesContributor.contribute(HibernateTypesContributor.java:34)
    at org.hibernate.boot.internal.MetadataBuilderImpl.applyTypes(MetadataBuilderImpl.java:296)

my pom.xml (only dependencies affected):

<!-- versions -->
    <hibernate-core.version>6.2.5.Final</hibernate-core.version>
    <hibernate-types.version>2.16.3</hibernate-types.version>
    <postgresql.version>42.5.4</postgresql.version>
    <spring.boot.version>3.0.6</spring.boot.version>
    
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
      <version>${spring.boot.version}</version>
    </dependency>
    <dependency>
      <groupId>com.vladmihalcea</groupId>
      <artifactId>hibernate-types-52</artifactId>
      <version>${hibernate-types.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>${hibernate-core.version}</version>
      <scope>compile</scope>
    </dependency>

application properties :


  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect

java version : 17

like image 432
Heri.R Avatar asked Mar 23 '26 17:03

Heri.R


2 Answers

Take note that you are still using hibernate-types52 which refers to previous major hibernate 5+. You should refer to the latest hibernate-types60 dependency to fully migrate to hibernate 6+. As of time, you can use the following:

<dependency>
        <groupId>com.vladmihalcea</groupId>
        <artifactId>hibernate-types-60</artifactId>
        <version>2.21.1</version>
</dependency>
like image 190
Baris Dogan Avatar answered Mar 26 '26 08:03

Baris Dogan


Upgraded to java 21 and Springboot 3.3.0 faced similar issues and the solution was replacing the hibernate-types-52 dependency with the newer version of the project which has been renamed to hypersistence-utils. Link to project documentation hypersistence-utils

<dependency>
   <groupId>io.hypersistence</groupId>
   <artifactId>hypersistence-utils-hibernate-63</artifactId>
   <version>3.7.6</version>
</dependency>
like image 40
Valentine Tobah Avatar answered Mar 26 '26 07:03

Valentine Tobah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!