Affects: spring-boot 3.1.x
I run into the following issue when manually constructing a LocalSessionFactoryBean
with the last spring-boot version.
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.orm.hibernate5.LocalSessionFactoryBuilder.scanPackages(LocalSessionFactoryBuilder.java:350)
The following method did not exist:
'void org.springframework.orm.hibernate5.LocalSessionFactoryBuilder.addAttributeConverter(java.lang.Class)'
The calling method's class, org.springframework.orm.hibernate5.LocalSessionFactoryBuilder, was loaded from the following location:
jar:file:/home/user/.m2/repository/org/springframework/spring-orm/6.0.13/spring-orm-6.0.13.jar!/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.class
The called method's class, org.springframework.orm.hibernate5.LocalSessionFactoryBuilder, is available from the following locations:
jar:file:/home/user/.m2/repository/org/springframework/spring-orm/6.0.13/spring-orm-6.0.13.jar!/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.class
The called method's class hierarchy was loaded from the following locations:
org.springframework.orm.hibernate5.LocalSessionFactoryBuilder: file:/home/user/.m2/repository/org/springframework/spring-orm/6.0.13/spring-orm-6.0.13.jar
org.hibernate.cfg.Configuration: file:/home/user/.m2/repository/org/hibernate/orm/hibernate-core/6.2.13.Final/hibernate-core-6.2.13.Final.jar
The issue relates to the following code change in hibernate: https://github.com/hibernate/hibernate-orm/commit/7b493f30fbaba8c50aae4959dbab87136b6c8226
So I guess all spring-boot versions where hibernate is updated to >= 6.2.0 are affected.
I created a minimal spring-boot application to reproduce the issue: https://github.com/d-rk/spring-session-factory-issue
Comment From: snicoll
So I guess all spring-boot versions where hibernate is updated to >= 6.2.0 are affected.
@d-rk unfortunately, this configuration style is no longer supported, see the reference guide:
Hibernate ORM 6.x is only supported as a JPA provider (HibernateJpaVendorAdapter). Plain SessionFactory setup with the orm.hibernate5 package is not supported anymore. We recommend Hibernate ORM 6.1/6.2 with JPA-style setup for new development projects.
You'd need to move this to plain JPA setup and that hibernate5
package should be a strong hint that it's not supposed to work with Hibernate 6.