Draft: Establish JPA 4 compatibility baseline with minimal changes - #4296
Draft: Establish JPA 4 compatibility baseline with minimal changes#4296oscarfanchin wants to merge 15 commits into
Conversation
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
Signed-off-by: Oscar Fanchin <oscar.fanchin@gmail.com>
|
Just a small follow-up: I intend to keep this PR in draft until Hibernate ORM 8 reaches the RC stage, since the underlying APIs are still evolving. The goal of this PR is not to provide a complete and final Jakarta Persistence 4 migration at this stage. It is deliberately a minimal adaptation of the current baseline, intended to provide a working starting point for the subsequent changes and to avoid discovering major integration issues only at the last minute. I’m keeping the branch aligned with the latest JPA 4.0 and Hibernate ORM 8 changes and periodically testing the integration as the APIs evolve. In the meantime, some initial triage on the overall migration direction would be very useful. I’m not requesting a full code review yet; I would mainly like to understand whether this baseline approach is aligned with the Spring Data JPA roadmap and whether the AOT named-query discovery issue described above should be addressed here or coordinated with Hibernate ORM. @mp911de — since you opened #4187, some initial directional feedback on this baseline would be greatly appreciated. Thank you for your attention and for all the work you do on the project. |
| @SuppressWarnings("unchecked") | ||
| public TypedQuery<Long> doCreateCountQuery(JpaParametersParameterAccessor accessor) { | ||
| return (TypedQuery<Long>) countQuery.createQuery(accessor); | ||
| return (TypedQuery<Long>) (countQuery.createQuery(accessor).unwrap(TypedQuery.class)); |
There was a problem hiding this comment.
Nit: Adding a instanceof check would be helpful with a fallback to unwrap(…).
|
Thanks for having a look. The PR description is LLM-bloated and, especially the state on how many tests ran etc. 😉 A full move to a JPA 4.0 baseline requires a broader refactoring towards I suggest keeping this change with a focus on #4197 to enable compatibility with Hibernate 7 and 8. Bridging the breaking changes between these versions requires some reflective glue. Consequently, our CI should run tests against both versions. For now, the breaking changes appear to be limited to |
hi @mp911de First of all, thank you for the review and for taking the time to look into this.
Are you suggesting the first model, mainly to keep the codebase ready for the eventual baseline upgrade, or the second one, where the artifact compiled against JPA 3.2 must already support Hibernate 8 at runtime? |
|
It is indeed the second variant. We do not intend to produce another artifact or version. Instead, the same Spring Data JPA version should support both Hibernate 7 with JPA 3.2 and Hibernate 8 with JPA 4.0. For the November release, this approach leaves us with a JPA 3.2 baseline. Moving the baseline to JPA 4.0 and Hibernate 8.0, together with a compatible EclipseLink version, will require some more time until all involved parties are ready. There seems to be very little movement in EclipseLink who released their 5.0 GA version only just recently. I therefore assume EclipseLink being one of the later JPA 4.0 adopters leaving us with the possibility to raise the JPA baseline only at a later time, maybe even with a Spring Data 5.0 release. I am happy to get more perspectives for better consideration. |
|
hi @mp911de, |
|
Closing this one: superseded by #4307, which takes the single-artifact direction. Discussion continues there. |
Summary
This draft provides an exploratory compatibility baseline for Jakarta Persistence 4 and Hibernate ORM 8.
The goal is to compile and run the existing Spring Data JPA functionality against this new baseline, validate the migration direction, and identify follow-up work.
This is not a complete or final support statement.
Scope
Support for new Jakarta Persistence 4 features is intentionally out of scope.
Intentional exclusions
Dependency baseline
This branch currently uses snapshot dependencies where required because the relevant Hibernate ORM and Jakarta Persistence APIs are still evolving.
More stable milestone builds are available, but they do not yet provide the compatibility surface required by this draft.
Current status
Test command:
mvn -pl spring-data-jpa -Pall-dbs clean process-test-classes
surefire:test@unit-test
surefire:test@integration-test
surefire:test@mysql-test
surefire:test@postgres-test
surefire:test@oracle-test
-Dmaven.test.failure.ignore=true -U
Full Surefire reports from the test run are attached.
surefire-reports.zip
AOT note
The remaining AOT failures originate from named-query discovery in
QueriesFactory.With the current Hibernate ORM 8 baseline, untyped named queries may be represented by a
TypedQueryReferencewhose result type isnull.QueriesFactorycurrently probes multiple result-type candidates, includingnull, when looking up named queries. Passing thenullcandidate toEntityManagerFactory.getNamedQueries(Class<R>)results in an NPE.Removing the
nullcandidate avoids the NPE but does not solve the underlying problem: untyped named queries can no longer be discovered. This causes AOT repository method contributions to be omitted and produces cascading metadata and integration-test failures.This behavior needs further discussion and dedicated follow-up work, potentially involving coordination with Hibernate ORM.
Related issues
Related to #4187
Related to #4197