java 与 java8 兼容的最低休眠版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25360927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 07:53:10  来源:igfitidea点击:

minimum hibernate version compatible with java8

javahibernatejava-8tomee

提问by Emmanuel Touzery

I have a terrible time trying to find out which is the minimum version of Hibernate that supports being run on a java8 JRE, where the user code will use java8 features.

我在试图找出支持在 java8 JRE 上运行的最低 Hibernate 版本时遇到了很糟糕的时间,其中用户代码将使用 java8 功能。

I found this bug, but it talks about making use of java8 features in hibernate, it's planned for hibernate 5.2 and for sure hibernate 4.3.1 already supports java8, since Wildfly ships it and claims to fully support java8.

我发现了这个错误,但它谈到在 hibernate 中使用 java8 功能,它计划用于 hibernate 5.2,并且可以肯定 hibernate 4.3.1 已经支持 java8,因为 Wildfly 发布了它并声称完全支持 java8。

I've tried to find in the hibernate bug trackerbugs related to java8, but again all are "too new".

我试图在 hibernate 错误跟踪器中找到与 java8 相关的错误,但同样都是“太新”。

Finally I've searched in the Hibernate release notes for .0 versions, and again without success: it seems the release notes will only describe the changes since the previous RC or beta release... I tried tracking all RC and beta releases for 4.3.0.Final and 4.2.0.Final but failed finding such a mention.

最后,我在 Hibernate 发行说明中搜索了 .0 版本,但再次没有成功:似乎发行说明只会描述自上一个 RC 或 beta 版本以来的更改......我尝试跟踪 4.3 的所有 RC 和 beta 版本.0.Final 和 4.2.0.Final 但未能找到这样的提及。

We are currently using Hibernate 4.2.12.Final and I wonder whether we could just start using java8 or whether we need to upgrade to a newer version of hibernate (4.3.x presumably).

我们目前正在使用 Hibernate 4.2.12.Final,我想知道我们是否可以开始使用 java8 或者我们是否需要升级到更新版本的 hibernate(大概是 4.3.x)。

For some context, we are using TomEE as an application server. The 1.7.0 is just released with support for java8. However in case we must upgrade to hibernate 4.3.x, I'm a bit afraid that we can't use Hibernate 4.3.x together with TomEE as I've seen this: "However, Hibernate 4.3+ (JPA 2.1) is not supported by TomEE, because it's Java EE 7.". So we'd rather stick to 4.2.x a bit longer if possible.

对于某些上下文,我们使用 TomEE 作为应用程序服务器。1.7.0 刚刚发布,支持 java8。但是,如果我们必须升级到 hibernate 4.3.x,我有点担心我们不能将 Hibernate 4.3.x 与 TomEE 一起使用,因为我已经看到了这一点:“但是,Hibernate 4.3+(JPA 2.1)不是TomEE 支持,因为它是 Java EE 7。” . 因此,如果可能,我们宁愿坚持使用 4.2.xa 更长的时间。

EDIT:well I found this, where someone says "we use hibernate (and 4.3.x supports java 8)". So it could be that 4.3.x is needed.

编辑:嗯,我找到了这个,有人说“我们使用休眠(并且 4.3.x 支持 java 8)”。所以可能需要 4.3.x。

采纳答案by dkatzel

It depends on what you mean by "user code will use java8 features". At my place of employment, we still use an ancient version of Hibernate 3 and Java 8 and it works fine. However, none of our entities use Java 8 features, only code that uses our entities do.

这取决于您所说的“用户代码将使用 java8 功能”是什么意思。在我工作的地方,我们仍然使用旧版本的 Hibernate 3 和 Java 8,它运行良好。但是,我们的实体都没有使用 Java 8 功能,只有使用我们实体的代码才使用。

I think the problem with Hibernate and Java 8 would be related to knowing how to map entities that use lambdas or default methods and the new Optionalclass and timepackages.

我认为 Hibernate 和 Java 8 的问题与了解如何映射使用 lambda 或默认方法以及新Optional类和time包的实体有关。

If you don't need to map to those, you should be fine.

如果你不需要映射到那些,你应该没问题。

回答by Kunda

Besides runtime compatibility which was discussed in other answers, Hibernate offers the hibernate-java8module since version 5.0.x - which adds Java 8 specific support, mainly for the java.time package data types.

除了在其他答案中讨论的运行时兼容性之外,Hibernate 还提供了自 5.0.x 版以来的hibernate-java8模块 - 它添加了 Java 8 特定支持,主要用于 java.time 包数据类型。