Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SpringBoot 1.3.0 support hibernate 5?

I'm a little confused about SpringBoot's (1.3.0) support of Hibernate5. The reference lists a dependency on hibernate 4.3.11.Final but it also lists a dependency on SpringFramework 4.2.3 which includes Hibernate5 support.

Is it just a matter of adding the extra Hibernate5 dependencies to override what Boot bundles? Can someone please clarify for me?

like image 667
John Cartwright Avatar asked Dec 06 '15 23:12

John Cartwright


People also ask

Does spring boot support hibernate?

As their names suggest, these are the starting dependencies in Spring Boot. This dependency includes JPA API, JPA Implementation, JDBC, and the other necessary libraries. Since the default JPA implementation is Hibernate, this dependency is actually enough to bring it in as well.

Which version of Hibernate is compatible with spring 5?

Spring 5x is compatible with hibernate 4x unless you are using it as an implementation of JPA which might not be compatible. A suggestion would be using the latest hibernate.

What hibernate does in spring boot?

Hibernate is a java framework and ORM (Object Relation Mapping) tool that is used to provide the implementation of the JPA methods.

Which version of spring does spring boot 2.6 2 use?

Spring Boot 2.6 moves to new versions of several Spring projects: Spring Data 2021.1. Spring HATEOAS 1.4. Spring AMQP 2.4.


1 Answers

You can use either Hibernate 4.3 or Hibernate 5.0 with Spring Boot 1.3. As you've observed, Hibernate 4.3.x is the default version.

To use Hibernate 5.0 you should override the hibernate.version property in Spring Boot's dependency management. Assuming that you're using Maven:

<properties>
    <hibernate.version>5.0.5.Final</hibernate.version>
</properties>

When using Hibernate 5.0, the one big difference from using Hibernate 4.3.x is that you'll lose Spring Boot's custom naming strategy. Due to a breaking change made in Hibernate 5.0, you'll see a warning like this logged at startup:

2015-12-07 10:04:56.911  WARN 81371 --- [           main] org.hibernate.orm.deprecation            : HHH90000006: Attempted to specify unsupported NamingStrategy via setting [hibernate.ejb.naming_strategy]; NamingStrategy has been removed in favor of the split ImplicitNamingStrategy and PhysicalNamingStrategy; use [hibernate.implicit_naming_strategy] or [hibernate.physical_naming_strategy], respectively, instead.

If you dislike Hibernate 5's defaults, you can specify a custom implicit or physical naming strategy in Spring Boot's application.properties using the spring.jpa.properties.hibernate.implicit_naming_strategy and spring.jpa.properties.hibernate.physical_naming_strategy properties respectively.

like image 97
Andy Wilkinson Avatar answered Oct 04 '22 03:10

Andy Wilkinson