Repository navigation
Closed
Labels
Milestone
Description
Juergen Hoeller opened SPR-14327 and commented
Hibernate ORM 5.2 got released just in time for Spring Framework 4.3. Let's do everything we can to support it right away, in particular upgrading our spring-orm-hibernate5 build to 5.2 while retaining compatbility with 5.0 and 5.1.
Issue Links:
- Add support for Hibernate 5.2 [SPR-14334] #18906 Add support for Hibernate 5.2 ("is duplicated by")
- Compatibility with Hibernate ORM 5.1 [SPR-13480] #18059 Compatibility with Hibernate ORM 5.1
- Hibernate Envers listeners fail because EntityManager is closed too early when using JPA/JTA/Hibernate 5.2.8/Envers [SPR-15334] #19897 Hibernate Envers listeners fail because EntityManager is closed too early when using JPA/JTA/Hibernate 5.2.8/Envers
- NoSuchMethodError for SessionFactoryImplementor.getProperties() with Hibernate 5.1 [SPR-14365] #18937 NoSuchMethodError for SessionFactoryImplementor.getProperties() with Hibernate 5.1
- JDBC Connection to reset not identical to originally prepared Connection with Hibernate 5.2 [SPR-14393] #18966 JDBC Connection to reset not identical to originally prepared Connection with Hibernate 5.2
- HibernateTemplate not binary-compatible with Hibernate 5.0/5.1's Query type [SPR-14425] #18996 HibernateTemplate not binary-compatible with Hibernate 5.0/5.1's Query type
- Support for Hibernate ORM 5.3 [SPR-16303] #20850 Support for Hibernate ORM 5.3
- findDefaultEntityManagerFactory should consider EMF bean's primary flag [SPR-7549] #12206 findDefaultEntityManagerFactory should consider EMF bean's primary flag
- Hibernate5 LocalSessionFactoryBean does not translate javax.persistence exceptions [SPR-14455] #19024 Hibernate5 LocalSessionFactoryBean does not translate javax.persistence exceptions
- Scoped EntityManager bean cannot get unwrapped to Session (with Hibernate 5.2) [SPR-15010] #19577 Scoped EntityManager bean cannot get unwrapped to Session (with Hibernate 5.2)
0 votes, 11 watchers
Activity
spring-projects-issues commentedon Jun 2, 2016
Juergen Hoeller commented
This turns out to be a significant effort, with plenty of deprecations to deal with - including a relocated
Querytype - and even a hard change in theSession.getFlushMode()signature. We're reflectively adapting to it for the time being, but as of Spring 5, we should really be requiring Hibernate 5.2+ for those reasons.spring-projects-issues commentedon Jun 3, 2016
Oliver Drotbohm commented
Any chance we can backport this to 4.2? With that in place and some tweaks that already got working in Spring Data, we could even get Spring Boot 1.3 projects to use Hibernate 5.2 successfully.
spring-projects-issues commentedon Jun 3, 2016
Juergen Hoeller commented
I'd rather recommend a version override to Spring Framework 4.3 next to the Hibernate 5.2 override. The latter has way more implications than the former, and I'm not really keen on dragging the follow-up issues into our 4.2.x line.
spring-projects-issues commentedon Jun 5, 2016
Hantsy Bai commented
In Hibernate 5.2 , It seemsSession(org.hibernate.Session) changed the getFlushMode() method return type to javax.persistence.FlushModeType.
I got failure when I used Spring boot 1.3 and Hibernate 5.2.0.Final.
spring-projects-issues commentedon Jun 5, 2016
Oliver Drotbohm commented
The commits for that ticket fix exactly that. Note, that the tweaks only made it into Spring 4.3, not 4.2 (which is the version Boot 1.3 is currently based on).
Boot 1.3 with Hibernate 5 is going to be a tough call, also due to the many changes that were introduced in 5.0 and the necessary tweaks to the existing auto-configuration for JPA. So while there is a theoretical chance you get it to work by upgrading Spring Framework to 4.3 snapshots (as GA is not released yet) and disabling all JPA related auto configuration and configure it manually, we highly recommend to wait for the Spring Boot 1.4 RC coming next, which will be based on Spring Framework 4.3 GA and have all the necessary tweaks to the auto-configuration built in so that Hibernate 5 (in whatever minor version) should be a pleasant experience.
spring-projects-issues commentedon Jun 5, 2016
Hantsy Bai commented
I am trying to upgrade to Spring Boot 1.4 M3, and got another issues the spring-boot-starter-data-jpa depends on hibernate-entitymanager, which is moved to Hibernate 5.2 core.
I have just noticed this issue. Most of the time, I used Hibernate as JPA provider by default.
Why spring-boot-starter-data-jpa depends on hibernate directly, not Java EE JPA API spec? which means we can not use OpenJPA, EclipseLink for JPA provider?
spring-projects-issues commentedon Jun 5, 2016
Oliver Drotbohm commented
Hibernate 5.2 was released two days ago. The Boot milestone was released way before that. Plus, it's the Hibernate guys that decided to change the artifact structure in a minor release and thus render Hibernate 5.2 unusable with the currently released Spring Boot Data JPA starter.
The starter is just a convenience mechanism to get JPA up and running with the most popular JPA provider. Read up on the starters in Boot's reference documentation. That said, nothing forces you to use the starter in the first place. You could either stick to it, exclude Hibernate and pull in the persistence provider of your choice manually (like shown here or just don't use the starter at all and manually declare all dependencies you want.
Generally speaking, I think we're moving away from the purpose of the ticket, which was putting the necessary tweaks in Spring Framework in place to make sure it works with Hibernate 5.2. Everything that needs to be done in Spring Data JPA is tracked in DATAJPA-911, everything for Spring Boot is tracked in this ticket. For more general questions on how to use the starters, please use StackOverflow and the Spring Boot Gitter channel.
spring-projects-issues commentedon Jun 10, 2016
Holger Stenzhorn commented
I have just upgraded our application to Spring 4.3 GA and Hibernate 5.2 and it seems that both are not yet working 100% together. The following bean declaration works fine with Spring 4.3 GA and Hibernate 5.1:
...but using Spring 4.3 GA and Hibernate 5.2 it leads to the following exception:
spring-projects-issues commentedon Jun 10, 2016
Juergen Hoeller commented
This looks like a conflict between old
hibernate-entitymanagerclasses and newhibernate-coreclasses on your classpath. Please double-check that onlyhibernate-corein version 5.2 is on your classpath, and no variant ofhibernate-entitymanagerat all (since it's been merged intohibernate-coreas of 5.2).spring-projects-issues commentedon Jun 10, 2016
Holger Stenzhorn commented
Please disregard my last comment: Things work as they should! The problem was that the old (obviously cached) Hibernate 5.1 JAR files were wrongly used instead of the Hibernate 5.2 JAR files. Sorry for the noise! :(
spring-projects-issues commentedon Jul 1, 2016
Andrei Ivanov commented
5.2.1 is out, with
hibernate-entitymanageras well :)spring-projects-issues commentedon Jul 1, 2016
Juergen Hoeller commented
Upgrading the Spring Framework 4.3.1 build to it. However, we'll keep not declaring
hibernate-entitymanagerin our build since it doesn't make a difference usage-wise.It's nice for a seamless upgrade in Boot, of course! Makes the story much smoother there.
spring-projects-issues commentedon Jul 1, 2016
Andrei Ivanov commented
Indeed, I see the pom of
hibernate-entitymanager-5.2.1mentions it is deprecated, so it's better not to use it.spring-projects-issues commentedon Jul 12, 2016
Ashok commented
Will there be a migration path to hibernate 5.* in spring 4.3?
spring-projects-issues commentedon Jul 12, 2016
Ashok commented
Since Andrei Ivanov mentioned that
hibernate-entitymanager-5.2.1is deprecated (atleast as per its pom), will there be a migration path to hibernate 5.* in spring 4.3?spring-projects-issues commentedon Jul 12, 2016
Oliver Drotbohm commented
What do you mean with migration path? 5.2 shipped without a
hibernate-entitymanagerartifact as all code moved intohibernate-core. That made it hard for a lot of third party integrators (like Spring Boot) to consume the new artifacts and at the same time allow users to use old versions of Hibernate. For applications, this usually doesn't apply as there is a dedicated upgrade step. So upgrading your Spring application to Hibernate 5, you effectively need 3 steps:hibernate-core.There's nothing in Spring Framework code that needs to be tweaked.
spring-projects-issues commentedon Jul 13, 2016
Ashok commented
Thanks for the clarification.
Earlier, I did not fully grasp what Andrei meant by this statement.
Indeed, I see the pom of hibernate-entitymanager-5.2.1 mentions it is deprecated, so it's better not to use it.
spring-projects-issues commentedon Jul 13, 2016
Ashok commented
Now I get it.