-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Hibernate 5.2 breaks SessionFactory unwrapping #7250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Spring Boot does not have a direct support for Hibernate proprietary APIs (if you exclude the initialization stuff). This is why we don't expose a Having said that, I am not sure what we can do there. You're basically trying to expose a sub-type of the thing that is being created. Why don't you inject the |
Yeah, I unfortunately see your point. I suppose injecting the EntityManagerFactory where I need it, and unwrapping in-place is an option. Not a pretty one tho. Especially if the SessionFactory is injected in a lot of places. This approach from the linked SO thread seems the most reasonable, but fails with other error messages (maybe this is a fault on my side - will investigate). Anyhow, I at least wanted to point out that upgrading to Hibernate 5.2 might not be as straight forward as it seems at first glance. I don't depend on upgrading, but others might. |
We are aware that Hibernate 5.2 brings indeed some notable changes and we did our best to make that transparent if you're using JPA. Thanks for raising the issue though. |
I toyed around a bit with Hibernate 5.1 and 5.2 today, using Spring Boot 1.4.1. I then realized that neither my tests nor apps run with Hibernate 5.2. The source itself is outlined in the migration guide for 5.2:
This is a problem, because to my knowledge Spring Boot does not expose a SessionFactory bean. Because of this, I used a StackOverflow snipped, to unwrap it myself:
While that works with Hibernate 5.0 and 5.1, it does obviously not with Hibernate 5.2. Stack trace:
I also tried other approaches from the linked SO thread, but none of them work anymore because of the now circular dependency.
So - is there any way to obtain a SessionFactory at all with Hibernate 5.2 and Spring Boot? I followed and thus am aware of the issues Spring Boot encountered with Hibernate 5.2 while preparing 1.4, so I will accept a "This simply won't work" answer. However - this should then be stated in the documentation. Since right now, it reads like upgrading is a simple as changing the version property (#7230 (comment) for example).
Test project to show the issue:
springdatahibernate.zip
The text was updated successfully, but these errors were encountered: