minimum hibernate version compatible with java8

Emmanuel Touzery picture Emmanuel Touzery · Aug 18, 2014 · Viewed 19.9k times · Source

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.

Answer

dkatzel picture dkatzel · Aug 19, 2014

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.