-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix for #2330 causes Spring Data JPA to no longer run on any Hibernate version before 5.4 #2391
Comments
Generally, we guarantee only compatibility for the versions that we compile against. There is a fairly good chance that older or newer versions of implementations work with a particular Spring Data JPA version but there's no guarantee. A lot of things that we need to do in Spring Data JPA require the use of JPA implementation-specific code because either the JPA specification is interpreted differently by the JPA implementations or particular features are not exposed by the JPA spec itself. We can certainly investigate what can be done to avoid the hard requirement on |
Hello Mark, many thanks for looking into this. Let me start by explicitly stating that I fully agree with three statements that you made: (1) "we generally do not verify that Spring Data JPA runs on all maintained versions for specific JPA providers" (2) "a lot of things that we need to do in Spring Data JPA require the use of JPA implementation-specific code" (3) "we generally do not verify that Spring Data JPA runs on all maintained versions for specific JPA providers" But (and here finally comes my "but"... 😉) it should be in the Spring Data JPA project's interest that for the major providers, especially the "big two", you ensure "on demand" (i.e. when issues are raised such as in my case) that in fact not only the most recent release will work fine with Spring Data JPA, but also slightly older ones (which are still widely used in commercial products across the industry). In our case, due to the fact that we also desperately need commercial Infinispan support for Hibernate 2nd level cache, we are unfortunately tied to use the version of Hibernate that our vendor supports, and this currently still is the 5.3.x series (5.3.21 or later) on the most recent JBoss 7.4.x... This will help to ensure that your wide user base is able to follow you closely and use your latest and greatest releases (Spring Boot as well as Spring Data JPA) even though tied to older versions of the JPA providers. My proposal would be as follows: Spring Data JPA should try to ensure on a best effort basis that it still runs on "fairly recent" versions of Hibernate as well as TopLink/EclipseLink (and not just the latest). In case someone notifies you about an incompatibility (which is typically introduced through the provider-specific code around class org.springframework.data.jpa.provider.PersistenceProvider), you could detect particular versions with "breaking" API changes and keep the old versions of the version-specific PersistenceProvider code in addition to the new ones for a grace period. Technically, this could be done either by reflection, by selecting/configuring different Enum instance versions, or by using "other means" to detect provider version for different product versions of Hibernate (here: 5.3 and below, 5.4 and upwards). Just while I type this, I can already see that some activities happen (a pull request... 😄) - this is great work & listening to your user base! Thanks a million, Mark, for your kind support! 👍 |
…e to obtain IdClass attributes. We now use IdentifiableType.hasSingleIdAttribute() to detect whether a type should have an IdClass. hasSingleIdAttribute is defined to return false if an IdClass is being used. It could also return false in case multiple identifier attributes are in place (composite Id) which is a bit of a grey area. At least we avoid using Hibernate-specific API. Original pull request #2412 See #2330 Closes #2391
…e to obtain IdClass attributes. We now use IdentifiableType.hasSingleIdAttribute() to detect whether a type should have an IdClass. hasSingleIdAttribute is defined to return false if an IdClass is being used. It could also return false in case multiple identifier attributes are in place (composite Id) which is a bit of a grey area. At least we avoid using Hibernate-specific API. Original pull request #2412 See #2330 Closes #2391
Hello Spring Data JPA team,
I hope that you agree with me that the goal of your project is to provide a piece of software that supports any JPA 2 compliant provider, independent of whether it is the latest and greatest release or whether it might still be an older version of e.g. Hibernate.
In our case, due to the fact that we are tied to JBoss EAP 7.4 as the deployment platform, we mandatorily need to use Hibernate 5.3.x (5.3.23.Final-redhat-00001 as of 7.4.1.GA) as the JPA provider.
But it turns out that due to the fix for #2330 (#2330; 87da84b), Spring Data JPA no longer runs on any Hibernate version before 5.4.0, as the Spring Data JPA "org.springframework.data.jpa.provider.PersistenceProvider" for Hibernate, in its method getIdClassAttributes(PersistenceProvider.java:106), tries to access Hibernate class "org.hibernate.metamodel.model.domain.spi.IdentifiableTypeDescriptor" - but this class is only present in Hibernate versions 5.4.0 or newer.
This class has only been introduced into Hibernate ORM by the commit for "HHH-12713 - Make EntityGraph creation more convenient" (hibernate/hibernate-orm@d0fb16d), but is not existing in any Hibernate version before 5.4, which means when trying to use a current Spring Data JPA build (starting from 2.5.6) to access Hibernate version 5.3.x, you will get the following exception:
Can you please fix the PersistenceProvider implementation to still support older Hibernate releases as well (and fall back to its previous behaviour when it detects a Hibernate version < 5.4 which does not provide the class that it is trying to access)?
Many thanks for listening!
Andreas
The text was updated successfully, but these errors were encountered: