Skip to content

Commit 617905d

Browse files
committed
release details
1 parent 86ad10f commit 617905d

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

migration-guide.adoc

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Hibernate now baselines on Java 17. Newer Java versions may also be used.
6262

6363
* Type parameters:
6464
** 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.
6666
* New JPA features colliding with previous Hibernate extension features:
6767
** `Nulls` (JPA) v. `NullPrecedence` (Hibernate), including JPA's new `Order#getNullPrecedence()` returning `Nulls`
6868
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
126126

127127
`Session#load` methods have been removed in favor of `Session#getReference` which have the same semantic.
128128

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.
130135

131136
[[session-refresh]]
132137
==== Session#refresh
@@ -228,6 +233,8 @@ The effect can also often be mitigated using Hibernate's bytecode-based laziness
228233
* Removed `SqmQualifiedJoin` - all joins are qualified.
229234
* Both `NaturalIdLoadAccess#using(Map)` and `NaturalIdMultiLoadAccess#compoundValue()` have been removed in favor of `Map#of()`
230235
* 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`
231238

232239

233240

@@ -268,6 +275,20 @@ Quite a few (again, previously deprecated) methods on `Interceptor` have been re
268275
Additionally, `EmptyInterceptor` was removed. As `org.hibernate.Interceptor` now uses default methods, one can simply implement `Interceptor` to the same end.
269276

270277

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+
271292
[[misc-spi]]
272293
=== Miscellaneous
273294

@@ -413,10 +434,11 @@ The select list was inferred based on the `from` clause.
413434

414435
In Hibernate 6 we decided to deprecate this overload of `createQuery()`, since:
415436

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
417439
- the second query is truly ambiguous, with no obviously intuitive interpretation.
418440

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_.
420442
Migration paths include:
421443

422444
1. explicitly specify the `select` list,
@@ -440,11 +462,16 @@ List<X> result =
440462
[[flush-persist]]
441463
=== Session flush and persist
442464

443-
The removal of `CascadeType.SAVE_UPDATE` slightly changes the persist and flush behaviour to conform with Jakarta Persistence.
444465

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.
446472

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.
448475

449476
Consider the following model
450477

@@ -477,7 +504,7 @@ Assuming we have `c1` as a detached `Child`, the following code will now result
477504

478505
[source,java]
479506
----
480-
Parent parent = session.get( Parent.class, parentId );
507+
Parent parent = session.find( Parent.class, parentId );
481508
parent.addChild( c1 );
482509
----
483510

@@ -486,7 +513,7 @@ Instead, `c1` must first be re-associated with the Session using merge:
486513

487514
[source,java]
488515
----
489-
Parent parent = session.get( Parent.class, parentId );
516+
Parent parent = session.find( Parent.class, parentId );
490517
Child merged = session.merge( c1 );
491518
parent.addChild( merged );
492519
----
@@ -644,7 +671,9 @@ Now, `varchar(1)` is used by default.
644671
[[pools]]
645672
== Connection Pools
646673

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.
648675

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`.
650679

0 commit comments

Comments
 (0)