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
+40-11Lines changed: 40 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ Hibernate now baselines on Java 17. Newer Java versions may also be used.
62
62
63
63
* Type parameters:
64
64
** Affects much of the Criteria API - especially roots, joins, paths
65
-
** Affects much of the Graph API - see <<load-fetch-graphs>> for details.
65
+
** Affects much of the Entity Graph API - see <<load-fetch-graphs>> for details.
66
66
* New JPA features colliding with previous Hibernate extension features:
67
67
** `Nulls` (JPA) v. `NullPrecedence` (Hibernate), including JPA's new `Order#getNullPrecedence()` returning `Nulls`
68
68
colliding with Hibernate's `SqmSortSpecification#getNullPrecedence` returning `NullPrecedence`. Hibernate's form
@@ -126,7 +126,12 @@ A general theme in 7.0 has been to remove Hibernate-specific features that have
126
126
127
127
`Session#load` methods have been removed in favor of `Session#getReference` which have the same semantic.
128
128
129
-
NOTE: `Session#get` was not previously deprecated as `Session#load` was, so it was not appropriate to remove. Starting in 7.0, `Session#get` is considered deprecated, to be removed in 8.0. Per the deprecation notes, use `Session#find` instead.
129
+
130
+
[[session-get]]
131
+
==== Session#get
132
+
`Session#get` methods were deprecated in favor of the JPA-standard `Session#find`, and new overloads of `Session#find` were added.
133
+
134
+
NOTE: `Session#get` was not previously deprecated as `Session#load` was, so it was not appropriate to remove it.
130
135
131
136
[[session-refresh]]
132
137
==== Session#refresh
@@ -228,6 +233,8 @@ The effect can also often be mitigated using Hibernate's bytecode-based laziness
228
233
* Removed `SqmQualifiedJoin` - all joins are qualified.
229
234
* Both `NaturalIdLoadAccess#using(Map)` and `NaturalIdMultiLoadAccess#compoundValue()` have been removed in favor of `Map#of()`
230
235
* Removed `Session.LockRequest` - use `LockOptions` instead
236
+
* `SessionFactory.createEntityManager()` now returns `Session` for convenience
237
+
* `CommonQueryContract.setFlushMode()` was deprecated in favor of `setQueryFlushMode` accepting a `QueryFlushMode`
231
238
232
239
233
240
@@ -268,6 +275,20 @@ Quite a few (again, previously deprecated) methods on `Interceptor` have been re
268
275
Additionally, `EmptyInterceptor` was removed. As `org.hibernate.Interceptor` now uses default methods, one can simply implement `Interceptor` to the same end.
269
276
270
277
278
+
[[usertype]]
279
+
=== Changes to UserType and CompositeUserType
280
+
281
+
The API interfaces `UserType` and `CompositeUserType` leaked the SPI types `SharedSessionContractImplementor` and `SessionFactoryImplementor`, which was a layer-breaker.
282
+
283
+
The solution was to change the signature of `nullSafeSet()` and `nullSafeGet()` in `UserType` via deprecation of the previous declarations, and remove some unnecessary parameters from methods of the incubating interface `CompositeUserType`.
284
+
285
+
[[jfr-spi]]
286
+
=== JFR SPI
287
+
288
+
The types `EventMonitor` and `DiagonosticEvent` replace the now-deprecated SPIs `EventManager` and `HibernateMonitoringEvent` use for integration with Java Flight Recorder.
289
+
290
+
Hibernate now reports many more kinds of `DiagnosticEvent` to JFR.
291
+
271
292
[[misc-spi]]
272
293
=== Miscellaneous
273
294
@@ -413,10 +434,11 @@ The select list was inferred based on the `from` clause.
413
434
414
435
In Hibernate 6 we decided to deprecate this overload of `createQuery()`, since:
415
436
416
-
- it returns a raw type, resulting in compiler warnings in client code, and
437
+
- it returns a raw type `Query`, resulting in compiler warnings in client code,
438
+
- each query result must be explicitly cast from `Object` to the query result type, and
417
439
- the second query is truly ambiguous, with no obviously intuitive interpretation.
418
440
419
-
As of Hibernate 7, the method is remains deprecated, and potentially-ambiguous queries _are no longer accepted_.
441
+
As of Hibernate 7, the method remains deprecated, and potentially-ambiguous queries _are no longer accepted_.
420
442
Migration paths include:
421
443
422
444
1. explicitly specify the `select` list,
@@ -440,11 +462,16 @@ List<X> result =
440
462
[[flush-persist]]
441
463
=== Session flush and persist
442
464
443
-
The removal of `CascadeType.SAVE_UPDATE` slightly changes the persist and flush behaviour to conform with Jakarta Persistence.
444
465
445
-
Persisting a transient entity or flushing a manged entity with an associated detached entity having the association annotated with `cascade = CascadeType.ALL` or `cascade = CascadeType.PERSIST` throws now an `jakarta.persistence.EntityExistsException` if the detached entity has not been re-associated with the Session.
466
+
The removal of `CascadeType.SAVE_UPDATE` slightly changes the persist and flush behaviour to conform with the Jakarta Persistence specification.
467
+
468
+
Making a transient entity persistent or flushing a managed entity now results in an `jakarta.persistence.EntityExistsException` if:
469
+
470
+
- the entity has an association with `cascade = CascadeType.ALL` or `cascade = CascadeType.PERSIST`, and
471
+
- the association references a detached instance of the associated entity class.
446
472
447
-
To re-associate the detached entity with the Session the `Session#merge` method can be used.
473
+
To avoid this exception, the reference to the detached instance should be replaced with a reference to a managed instance associated with the current session.
474
+
Such a reference may be obtained by calling `merge()` or `getReference()` on the detached entity instance.
448
475
449
476
Consider the following model
450
477
@@ -477,7 +504,7 @@ Assuming we have `c1` as a detached `Child`, the following code will now result
@@ -644,7 +671,9 @@ Now, `varchar(1)` is used by default.
644
671
[[pools]]
645
672
== Connection Pools
646
673
647
-
We have decided to drop built-in support for the Vibur, Proxool and UCP Connection Pools. This is dues to a variety of reasons, a main one being that we are not able to properly test them.
674
+
We have decided to drop built-in support for the Vibur, Proxool and UCP Connection Pools for a variety of reasons - the main one being that we are not able to properly test them.
648
675
649
-
We recommend using Agroal or HikariCP instead; or implement the `ConnectionProvider` yourself to integrate with the Connection Pool of your choice (in fact other Connection Pools are known to ship implementations of the Hibernate `ConnectionProvider` already).
676
+
We recommend using https://github.com/agroal/agroal[Agroal] or https://github.com/brettwooldridge/HikariCP[HikariCP] instead.
677
+
Alternatively, you may implement the `ConnectionProvider` interface to integrate the connection pool of your choice.
678
+
In fact, some connection pools already include their own implementations of `ConnectionProvider`.
0 commit comments