SpringBoot 1.3.0支持hibernate 5吗?

我对SpringBoot(1.3.0)对Hibernate5的支持感到有些困惑。 该引用列出了对hibernate 4.3.11.Final的依赖,但它也列出了对SpringFramework 4.2.3的依赖,其中包括Hibernate5支持。

是否只需添加额外的Hibernate5依赖项来覆盖Boot bundle的内容? 有人可以为我澄清一下吗?

您可以在Spring Boot 1.3中使用Hibernate 4.3或Hibernate 5.0。 正如您所观察到的,Hibernate 4.3.x是默认版本。

要使用Hibernate 5.0,您应该在Spring Boot的依赖关系管理中覆盖hibernate.version属性。 假设你正在使用Maven:

  5.0.5.Final  

使用Hibernate 5.0时,与使用Hibernate 4.3.x的一个重大区别是,你将失去Spring Boot的自定义命名策略。 由于在Hibernate 5.0中进行了重大更改,您将在启动时看到这样的警告:

 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. 

如果您不喜欢Hibernate 5的默认值,可以分别使用spring.jpa.properties.hibernate.implicit_naming_strategyspring.jpa.properties.hibernate.physical_naming_strategy属性在Spring Boot的application.properties指定自定义隐式或物理命名策略。

2016年7月更新 :随着Spring Boot 1.4.0的发布,默认的Hibernate 5被用作默认的JPA持久性提供程序 。


现在有一个关于迁移到Hibernate 5的故障 – 似乎主要的挫折是一些名称策略不兼容。 现在,票证目前预定为1.4.0

多谢你们! 经过多次试验,这个解决方案对我来说就像一个魅力! 我实现了自定义策略并在application.yml中设置它们,如下所示:

  jpa: database: MYSQL database-platform: org.hibernate.dialect.MySQL5Dialect properties: hibernate: implicit_naming_strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl physical_naming_strategy: com.quicken.ups.entities.utils.DBFieldNamingStrategy