Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

minimum hibernate version compatible with java8

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.

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.

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

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.

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).

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.

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.

like image 680
Emmanuel Touzery Avatar asked Aug 18 '14 10:08

Emmanuel Touzery


People also ask

Which version of Hibernate is compatible with Java 11?

Hibernate 5.3 lists Java 11 as supported in the latest release 5.3. 22. Moreover, Hibernate 5.6 is also Java 11 compatible.


2 Answers

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.

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 Optional class and time packages.

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

like image 105
dkatzel Avatar answered Oct 05 '22 02:10

dkatzel


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

like image 30
Kunda Avatar answered Oct 05 '22 00:10

Kunda