@@ -11,15 +11,15 @@ This guide discusses migration to Hibernate ORM version 7.0. For migration from
11
11
earlier versions, see any other pertinent migration guides as well.
12
12
13
13
[[jpa-32]]
14
- == JPA 3.2
14
+ == Jakarta Persistence 3.2
15
15
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:
17
17
18
18
* type parameters
19
19
** Affects much of the Criteria API - especially roots, joins, paths
20
20
** Affects much of the Graph API -
21
21
*** 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.
23
23
* new JPA features colliding with previous Hibernate extension features
24
24
** `Nulls` (JPA) v. `NullPrecedence` (Hibernate), including JPA's new `Order#getNullPrecedence()` returning `Nulls`
25
25
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.
31
31
requiring changes to the Hibernate API.
32
32
** `Transaction#getTimeout`. JPA 3.2 adds `#getTimeout` but uses `Integer` whereas Hibernate has historically used `int`
33
33
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
+
34
56
35
57
[[annotation-validation]]
36
58
== Annotation Validations
@@ -60,10 +82,36 @@ private Employee manager;
60
82
----
61
83
62
84
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
+
63
111
[[java-beans]]
64
112
== JavaBean Conventions
65
113
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.
67
115
68
116
[source,java]
69
117
----
@@ -79,18 +127,11 @@ String isDefault();
79
127
* Removed `SqmQualifiedJoin`. All joins are qualified.
80
128
* Removed `AdditionalJaxbMappingProducer`, deprecated in favor of `AdditionalMappingContributor`
81
129
* Removed `MetadataContributor`, deprecated in favor of `AdditionalMappingContributor`
130
+ * Removed `@Persister`.
82
131
83
132
84
133
[[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