SpringBoot 1.3.0支持hibernate 5吗?

Joh*_*ght 15 java spring hibernate spring-boot hibernate-5.x

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

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

And*_*son 16

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

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

<properties>
    <hibernate.version>5.0.5.Final</hibernate.version>
</properties>
Run Code Online (Sandbox Code Playgroud)

使用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.
Run Code Online (Sandbox Code Playgroud)

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

  • 感谢您的详细解答,无论借口无知,您是否可以详细说明如何在不破坏任何已存在的情况下迁移到hibernate 5?是否有一个命名策略替代我们目前使用的那个`org.hibernate.cfg.ImprovedNamingStrategy`?或者也许它是一个更好的决定,暂时阻止Hibernate 5直到Spring引导正式迁移? (2认同)

dim*_*sli 6

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


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