You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migration-guide.adoc
+33-18Lines changed: 33 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,12 +15,12 @@ earlier versions, see any other pertinent migration guides as well.
15
15
16
16
7.0 migrates to Jakarta Persistence 3.2 which is fairly disruptive, mainly around:
17
17
18
-
* type parameters
18
+
* Type parameters:
19
19
** Affects much of the Criteria API - especially roots, joins, paths
20
20
** Affects much of the Graph API -
21
-
*** org.hibernate.graph.Graph.addAttributeNode(java.lang.String) defines a return while
21
+
*** `org.hibernate.graph.Graph.addAttributeNode(java.lang.String)` defines a return while
22
22
`jakarta.persistence.Graph.addAttributeNode(java.lang.String)` does not.
23
-
* new JPA features colliding with previous Hibernate extension features
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
26
26
was renamed to `SqmSortSpecification#getHibernateNullPrecedence` to avoid the collision.
@@ -86,18 +86,19 @@ private Employee manager;
86
86
=== Misplaced Annotations
87
87
88
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.
89
+
did not necessarily throw errors, in most cases these annotations were simply ignored.
90
90
91
+
For example, this code now results in an error:
91
92
92
93
[source,java]
93
94
----
94
95
@Entity
95
96
class Book {
96
-
// defines FIELD access-type
97
+
// specifies FIELD access, properties should not be annotated
97
98
@Id
98
99
Integer id;
99
100
100
-
// previously ignored, this is an error now
101
+
// previously ignored, this is an error now
101
102
@Column(name="category")
102
103
String getType() { ... }
103
104
}
@@ -114,7 +115,8 @@ versions did not validate this particularly well.
114
115
[[java-beans]]
115
116
=== JavaBean Conventions
116
117
117
-
Previous versions allowed some questionable (at best) attribute naming patterns. These are no longer supported. E.g.
118
+
Previous versions allowed some questionable (at best) attribute naming patterns.
119
+
For example, this property declaration is no longer allowed:
118
120
119
121
[source,java]
120
122
----
@@ -204,16 +206,16 @@ Applications will need to replace usages of the removed `@Proxy` annotation.
204
206
205
207
`@Proxy#proxyClass` has no direct replacement, but was also never needed/useful.
206
208
207
-
Here we focus on `@Proxy#laxy` attribute which, again, was hardly ever useful.
209
+
Here we focus on `@Proxy#lazy` attribute which, again, was hardly ever useful.
208
210
By default (true), Hibernate would proxy an entity when possible and when asked for.
209
211
"Asked for" includes calls to `Session#getReference` and lazy associations.
210
212
All such cases though are already controllable by the application.
211
213
212
214
* Instead of `Session#getReference`, use `Session#find`
213
-
* Use eager associations, using
214
-
** `FetchType.EAGER` (the default for to-one associations anyway), possibly combined with `@Fetch`
215
-
** `EntityGraph`
216
-
** `@FetchProfiles`
215
+
* Use eager association fetching, for example,
216
+
** `FetchType.EAGER` (the default for to-one associations anyway), possibly combined with `@Fetch`,
217
+
** `EntityGraph`, or a
218
+
** `@FetchProfile`.
217
219
218
220
The effect can also often be mitigated using Hibernate's bytecode-based laziness (possibly combined with `@ConcreteProxy`).
219
221
@@ -310,8 +312,8 @@ The previous behavior may be recovered by setting `hibernate.query.native.prefer
310
312
[[ddl-implicit-datatype-timestamp]]
311
313
== Default precision for `timestamp` on some databases
312
314
313
-
The default precision for Oracle timestamps was changed to 9 i.e. nanosecond precision.
314
-
The default precision for SQL Server timestamps was changed to 7 i.e. 100 nanosecond precision.
315
+
The default precision for Oracle timestamps was changed to 9, i.e. nanosecond precision.
316
+
The default precision for SQL Server timestamps was changed to 7, i.e. 100 nanosecond precision.
315
317
316
318
Note that these changes only affect DDL generation.
317
319
@@ -339,12 +341,12 @@ The migration requires to read data and re-save it.
339
341
To retain backwards compatibility, configure the setting `hibernate.type.preferred_array_jdbc_type` to `VARBINARY`.
340
342
341
343
[[xml-format-mapper-changes]]
342
-
== XML FormatMapper changes
344
+
== XML `FormatMapper` changes
343
345
344
346
Previous versions of Hibernate ORM used an undefined/provider-specific format for serialization/deserialization of
345
-
collections, maps and byte arrays to/from XML, which is not portable.
347
+
collections, maps and byte arrays to/from XML, which was not portable.
346
348
347
-
XML FormatMapper implementations were changed to now use a portable format for collections, maps and byte arrays.
349
+
XML `FormatMapper` implementations now use a portable format for collections, maps, and byte arrays.
348
350
This change is necessary to allow mapping basic arrays as `SqlTypes.XML_ARRAY`.
349
351
350
352
The migration requires to read data and re-save it.
@@ -365,7 +367,7 @@ To align with Jakarta Persistence (the 3.2 TCK tests this), Hibernate now consid
365
367
366
368
However, because `hibernate.session_factory_name` is also a trigger to attempt to bind the SessionFactory into JNDI,
367
369
this change to consider persistence-unit name, means that each `SessionFactory` created through Jakarta Persistence now
368
-
have a name and Hibernate attempted to bind these to JNDI.
370
+
has a name and Hibernate attempts to bind it to JNDI.
369
371
370
372
To work around this we have introduced a new `hibernate.session_factory_jndi_name` setting that can be used to explicitly
371
373
specify a name for JNDI binding. The new behavior is as follows (assuming `hibernate.session_factory_name_is_jndi` is not explicitly configured):
@@ -461,6 +463,19 @@ Hibernate now reports an error in this situation.
461
463
This includes auto-applied converters.
462
464
To suppress the error for an auto-applied converter, use `@Convert(disableConversion=true)`.
463
465
466
+
== `org.hibernate.graph` package
467
+
468
+
The `EntityGraph` API was enhanced in JPA 3.2, and made much more useful.
469
+
The package `org.hibernate.graph` contains extensions to that API, which have been significantly impacted by the migration to JPA 3.2, and by the additional of new functionality.
470
+
Furthermore, some legacy operations were declared with incorrect generic type signatures (by both JPA, and by Hibernate).
471
+
472
+
This package has been significantly re-engineered, and the impact of this effort includes:
473
+
474
+
- some breaking changes to type signatures, and
475
+
- a number of deprecations of legacy operations which are now covered by JPA.
476
+
477
+
We encourage migration to the use of the new JPA-standard operations.
478
+
464
479
== Deprecations
465
480
466
481
* `@Comment` is deprecated in favor of the JPA 3.2 `comment` members
0 commit comments