I'm in the process of upgrading a Spring Boot 2.7.7 + Hibernate 5 application to Spring Boot 3 and Hibernate 6. While updating I noticed that spring cloud spanner dialect latest v1.6.0 still refers to older hibernate package structure and coz of that getting as mentioned below and issue.
In Hibernate 6, As explained here this might be related to the new way of updating package structure for hibernate-core jar. This dependency needs to be updated to refer latest hibernate-core jar which recently moved to "org.hibernate.orm"
Spanner Dialect referring to old hibernate core
Hibernate core updates
I tried changing the dependencies manually to refer older hibernate-core however there is no luck. As you all may there are significant changes spring boot 3 brings in so had to fix this on priority as spring-web has critical vulnerability. Git Issue: https://github.com/GoogleCloudPlatform/google-cloud-spanner-hibernate/issues/556#issue-1592718169
ERROR SpringApplication Application run failed 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/tool/hbm2ddl/UniqueConstraintSchemaUpdateStrategy
Caused by: java.lang.NoClassDefFoundError: org/hibernate/tool/hbm2ddl/UniqueConstraintSchemaUpdateStrategy at com.google.cloud.spanner.hibernate.SpannerServiceContributor.contribute(SpannerServiceContributor.java:69)
Is there any workaround to fix this issue? or who can help form spanner hibernate dialect updates?
The Cloud Spanner Hibernate dialect in this repository only supports Hibernate 5.4.
Hibernate 6.x comes with the Spanner dialect built-in: https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java
So the following should work:
google-cloud-spanner-hibernate-dialect
from your project.SpannerDialect
built-in.google-cloud-spanner-jdbc
.org.hibernate.dialect.SpannerDialect
. This is the fully qualified class name of the built-in Spanner dialect in Hibernate 6.x.