minimum hibernate version compatible with java8
Asked Answered
D

2

12

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.

Duodecillion answered 18/8, 2014 at 10:15 Comment(0)
H
7

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.

Halvaard answered 19/8, 2014 at 13:50 Comment(5)
I was reading about OpenJPA and I think their bytecode manipulation code (needed for lazy loading and so on) was not compatible with the new java8 bytecode instructions. In the case of OpenJPA I think they needed to upgrade the asm library that they were using. I'm assuming there is a similar problem with hibernate but if you're right it's even better (and it would explain why they never really advertised the java8 support).Duodecillion
(then I may have misunderstood even then OpenJPA case, maybe they could not BUILD with java8 but could RUN on java8...). Difficult to be 100% sure.Duodecillion
@EmmanuelTouzery I don't know, we don't even use OpenJPA but just raw hibernate so it isn't a problem for us at least.Halvaard
my point was that for instance tomee 1.6.0 is not compatible with java8, same with glassfish 3.1.2.2. Those applications will crash when ran under java8. I assumed that would be the case for older versions of hibernate, maybe that is not the case after all (I wonder if maybe it works for you just "by luck" and tomorrow you start using some advanced hibernate feature and it'll break).Duodecillion
Well, we are testing our setup with hibernate 4.2 on java8 and indeed can't notice any problems so far. So until proven wrong, I'm going to assume you are right and that there was never a compatibility problem for any relatively recent version of Hibernate. Thank you!Duodecillion
S
2

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.

Sitzmark answered 18/9, 2017 at 7:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.