Skip to content

Commit b7778e1

Browse files
committed
HHH-17504 - Ongoing JPA 3.2 work
1 parent d030d32 commit b7778e1

File tree

2 files changed

+57
-48
lines changed

2 files changed

+57
-48
lines changed

hibernate-core/src/main/java/org/hibernate/annotations/Persister.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

migration-guide.adoc

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ This guide discusses migration to Hibernate ORM version 7.0. For migration from
1111
earlier versions, see any other pertinent migration guides as well.
1212

1313
[[jpa-32]]
14-
== JPA 3.2
14+
== Jakarta Persistence 3.2
1515

16-
7.0 migrates to JPA 3.2 which is fairly disruptive, mainly around:
16+
7.0 migrates to Jakarta Persistence 3.2 which is fairly disruptive, mainly around:
1717

1818
* type parameters
1919
** Affects much of the Criteria API - especially roots, joins, paths
2020
** Affects much of the Graph API -
2121
*** org.hibernate.graph.Graph.addAttributeNode(java.lang.String) defines a return while
22-
1jakarta.persistence.Graph.addAttributeNode(java.lang.String)` does not.
22+
`jakarta.persistence.Graph.addAttributeNode(java.lang.String)` does not.
2323
* new JPA features colliding with previous Hibernate extension features
2424
** `Nulls` (JPA) v. `NullPrecedence` (Hibernate), including JPA's new `Order#getNullPrecedence()` returning `Nulls`
2525
colliding with Hibernate's `SqmSortSpecification#getNullPrecedence` returning `NullPrecedence`. Hibernate's form
@@ -31,6 +31,28 @@ earlier versions, see any other pertinent migration guides as well.
3131
requiring changes to the Hibernate API.
3232
** `Transaction#getTimeout`. JPA 3.2 adds `#getTimeout` but uses `Integer` whereas Hibernate has historically used `int`
3333

34+
See this https://in.relation.to/2024/04/01/jakarta-persistence-3/[blog post] for a good discussion of the changes in Jakarta Persistence 3.2.
35+
36+
37+
[[hibernate-models]]
38+
== Hibernate Models
39+
40+
For many years Hibernate has used the Hibernate Commons Annotations (HCANN) library for handling various low-level tasks
41+
related to understanding the structure of an application domain model, reading annotations and weaving in XML
42+
mapping documents.
43+
44+
However, HCANN suffers from a number of limitations that continue to be problematic. And given
45+
the use of HCANN across multiple projects, doing the needed refactoring was simply not possible.
46+
47+
The https://github.com/hibernate/hibernate-models[Hibernate Models] project was developed to be a better alternative
48+
to HCANN. Hibernate Models is essentially an abstraction over reflection (`Type`, `Class`, `Member`, ...) and
49+
annotations. Check out its project page for complete details.
50+
51+
7.0 uses Hibernate Models in place of HCANN.
52+
53+
NOTE: Currently, the `hibernate-envers` module still uses HCANN. That will change during continued 7.0 development.
54+
55+
3456

3557
[[annotation-validation]]
3658
== Annotation Validations
@@ -60,10 +82,36 @@ private Employee manager;
6082
----
6183

6284

85+
[[misplaced-annotations]]
86+
=== Misplaced Annotations
87+
88+
7.0 does much more in-depth checking that annotations appear in the proper place. While previous versions
89+
did not necessarily throw errors, in most cases these annotations were simply ignored. E.g.
90+
91+
92+
[source,java]
93+
----
94+
@Entity
95+
class Book {
96+
// defines FIELD access-type
97+
@Id
98+
Integer id;
99+
100+
// previously ignored, this is an error now
101+
@Column(name="category")
102+
String getType() { ... }
103+
104+
...
105+
}
106+
----
107+
108+
109+
110+
63111
[[java-beans]]
64112
== JavaBean Conventions
65113

66-
Previous versions allowed some, at beast, questionable attribute naming patterns. These are no longer supported. E.g.
114+
Previous versions allowed some questionable (at best) attribute naming patterns. These are no longer supported. E.g.
67115

68116
[source,java]
69117
----
@@ -79,18 +127,11 @@ String isDefault();
79127
* Removed `SqmQualifiedJoin`. All joins are qualified.
80128
* Removed `AdditionalJaxbMappingProducer`, deprecated in favor of `AdditionalMappingContributor`
81129
* Removed `MetadataContributor`, deprecated in favor of `AdditionalMappingContributor`
130+
* Removed `@Persister`.
82131

83132

84133
[[todo]]
85-
== Todos
86-
87-
NOTE:: Look for `// todo (jpa 3.2)`
88-
89-
* {@linkplain SqmCrossJoin} and its offspring are largely de-typed to account
90-
for {@linkplain SqmCrossJoin} having only one type argument for the right-hand
91-
side. To properly handle the type parameters in the hierarchy we need to change this to
92-
accept type parameter for the left-handle side as well - breaking change.
93-
* The changes in `jakarta.persistence.EntityManager#createNativeQuery(java.lang.String, java.lang.Class<?>)` are really unfortunate.
94-
Previously that signature was `(java.lang.String, java.lang.Class)` and our override of that was able to be
95-
`<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass)`. JPA adding that wildcard means our
96-
override is no longer valid. I had to change that to ``
134+
== Todos (dev)
135+
136+
* Look for `todo (jpa 3.2)` comments
137+
* Look for `todo (7.0)` comments

0 commit comments

Comments
 (0)