Restore support for Hibernate 4.2.x in Boot 1.2
In the commit 8219f2be4 a dependency on the class org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform was added to HibernateJpaAutoConfiguration, however in Hibernate 4.2.x the package is different: org.hibernate.service.jta.platform.internal.NoJtaPlatform.
Is it intended to remove support for Hibernate 4.2.x with Spring Boot 1.2.0?
Spring Boot has always used and supported Hibernate 4.3.x. I don't think it's right to say that support for 4.2 has been removed as it was never intentionally provided in the first place.
Is there something preventing you from using 4.3?
Yeah, WebSphere :(
But on the other hand, in the HibernateEntityManagerCondition there are both Entitymanager classes, from 4.2 and 4.3:
private static String[] CLASS_NAMES = {
"org.hibernate.ejb.HibernateEntityManager",
"org.hibernate.jpa.HibernateEntityManager" };
Shouldn't this condition then only be true, when the class from Hibernate 4.3 is present?
I guess that means we do explicitly support Hibernate 4.2. When Boot was 1.0 I think Spring Data was still on 4.2.
For the moment i hacked a workaround in my application, but if you want, i can provide a fix for that, so that it works with Hibernate 4.2 (would be my first contribution to Spring Boot, so i'm not sure, if i get it all correct).
Contributions are definitely welcome. If it's the same order of hack as we already have then it's probably acceptable. Read the guidelines in CONTRIBUTING.adoc and make sure you fill in the contributors agreement (link in README).
I have created a pull request (https://github.com/spring-projects/spring-boot/pull/1476) to disable the HibernateJpaAutoConfiguration for Hibernate 4.2, because otherwise you get NoClassDefFoundErrors. I think, the only way to readd Hibernate 4.2 support would be to create a new module, where we could add Hibernate 4.2 as dependency to compile the auto configuration class. But on the other hand i think it would get out of hand to create modules for every dependency, which introduces such changes between two versions.
Because i have configured the JTA platform with a property, i have just copied the class in my project and removed the customizeVendorProperties as a quick workaround.
Rather than disabling auto-configuration with Hibernate 4.2, would it not be possible to access JtaPlatform.INSTANCE using reflection?
The SpringJtaPlatform class also depends on the new package structure (extends AbstractJtaPlatform), so then that would also have to be initialized by reflection. If that's ok for you, i can change that, but i wasn't sure, if that's a good style (well, surely it isn't).
We could drop (or rather fail to add) support for Hibernate 4.2 and JTA? There has to be a fairly clear boundary to the hacks to make them worthwhile.
FWIW this is approximately the same level of hackery we employ to support Tomcat 8 as well as 7. Jetty 9 is not supportable because it gets too convoluted (too many API changes).
I would be ok with that (hence my patch). I have created a blog post, where i explained my hack, so anyone who has the same problem will sooner or later stumble upon that (http://www.mdoninger.de/2014/08/31/spring-boot-1-2-0-with-Hibernate-4-2/ for anyone who's interested).
I'd recommend declaring Hibernate-JTA auto-configuration as only working on Hibernate 4.3+. If the rest of Boot's Hibernate support keeps working with Hibernate 4.2, that has to be good enough.
Sounds good to me. I was a bit surprised when @mdoninger pointed out that we ever had 4.2 support of any sort
The main problem with Hibernate 4.2 vs 4.3 is that the latter is JPA 2.1 based... which means that people on EE 6 servers without a JPA 2.1 API patch can only really use Hibernate 4.2, at least when bootstrapping it through the JPA setup contract. That's the main reason why we'll keep supporting Hibernate 4.2+ for the entire Spring Framework 4.x line, while recommending Hibernate 4.3 these days.
I'll try to implement that with some reflection (i guess i can provide a first pull request on friday or saturday).
I've pushed an implementation, where i load the specific Hibernate related classes with reflection. Please give me some feedback about the error handling, i couldn't find any other classes with a similar behaviour, so i'm not sure, if logging is enough, or if there should be any other actions (like rethrowing exceptions etc.).