Skip to content

Commit ee18033

Browse files
authored
Changes where release details live (#9919)
* release details
1 parent f1251ea commit ee18033

6 files changed

+146
-358
lines changed

Diff for: migration-guide.adoc

+68-161
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:versionDocBase: {docsBase}/7.0
66
:userGuideBase: {versionDocBase}/userguide/html_single/Hibernate_User_Guide.html
77
:javadocsBase: {versionDocBase}/javadocs
8+
:releaseSeriesBase: https://hibernate.org/orm/releases/7.0/
89
:fn-cascase-type: footnote:cascade-type[`org.hibernate.annotations.Cascade` and `org.hibernate.annotations.CascadeType` are both fully deprecated as of 7.0]
910

1011
This guide discusses migration to Hibernate ORM version 7.0. For migration from
@@ -44,10 +45,15 @@ This required a few actions on our part:
4445
[[requirements]]
4546
== Requirements
4647

47-
* Java 17, or greater
48+
* <<java-17>>, or greater
4849
* <<jpa-32>>
4950
* <<hibernate-models>>
5051

52+
[[java-17]]
53+
=== Java 17
54+
55+
Hibernate now baselines on Java 17. Newer Java versions may also be used.
56+
5157

5258
[[jpa-32]]
5359
=== Jakarta Persistence 3.2
@@ -70,6 +76,9 @@ This required a few actions on our part:
7076

7177
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.
7278

79+
- https://ci.hibernate.org/view/ORM/job/hibernate-orm-tck-3.2/job/wip%252F7.0/24/[TCK Results] with Java 17
80+
- https://ci.hibernate.org/view/ORM/job/hibernate-orm-tck-3.2/job/wip%252F7.0/25/[TCK Results] with Java 21
81+
7382
[[hibernate-models]]
7483
=== Hibernate Models
7584

@@ -94,144 +103,8 @@ annotations. Check out its project page for complete details.
94103
[[new-features]]
95104
== New Features
96105

97-
New features introduced in 7.0...
98-
99-
[[soft-delete-timestamp]]
100-
=== @SoftDelete with TIMESTAMP
101-
102-
Soft-delete now supports the strategy of tracking the timestamp at which the soft-delete occurred,
103-
in addition to the previous truth-based strategies.
104-
See the link:{user-guide-url}#soft-delete[User Guide] for details.
105-
106-
107-
[[embedded-column-naming]]
108-
=== @EmbeddedColumnNaming
109-
110-
A long-requested feature for both Hibernate and Jakarta Persistence has been the ability to
111-
define a prefix for the names of columns associated with an embedded value.
112-
113-
7.0 adds support for this using the new `@EmbeddedColumnNaming` annotation. The annotation
114-
accepts a format pattern, so is a little more flexible than just a prefix.
115-
116-
Consider a typical `Person` / `Address` composition:
117-
118-
[source,java]
119-
----
120-
@Embeddable
121-
class Address {
122-
String street;
123-
String city;
124-
...
125-
}
126-
127-
@Entity
128-
class Person {
129-
...
130-
131-
@Embedded
132-
@EmbeddedColumnNaming("home_%")
133-
Address homeAddress;
134-
135-
@Embedded
136-
@EmbeddedColumnNaming("work_%")
137-
Address workAddress;
138-
139-
}
140-
----
141-
142-
This instructs Hibernate to use the column names `home_street`, `home_city`, `work_street`, and so on.
143-
144-
See the link:{user-guide-url}#embeddable-column-naming[User Guide] for details.
145-
146-
[[NamedEntityGraph]]
147-
=== @NamedEntityGraph
148-
149-
A new annotation (`@org.hibernate.annotations.NamedEntityGraph`) has been added to allow
150-
specifying a named entity-graph using Hibernate's ability to parse a string representation of the graph.
151-
152-
153-
[source,java]
154-
----
155-
@Entity
156-
@NamedEntityGraph( graph="title, isbn, author( name, phoneNumber )" )
157-
class Book {
158-
// ...
159-
}
160-
----
161-
162-
163-
See `org.hibernate.graph.GraphParser` for details on the syntax and the
164-
link:{user-guide-url}#fetching-strategies-dynamic-fetching-entity-graph-parsing-annotation[User Guide] for additional details.
165-
166-
167-
[[enum-checks]]
168-
=== Converted Enums and Check Constraints
169-
170-
Hibernate previously added support for generating check constraints for enums mapped using `@Enumerated`
171-
as part of schema generation. 7.0 adds the same capability for enums mapped using an `AttributeConverter`,
172-
by asking the converter to convert all the enum constants on start up.
173-
174-
[[hbm-transform]]
175-
=== hbm.xml Transformation
176-
177-
Hibernate's legacy `hbm.xml` mapping schema has been deprecated for quite some time, replaced by a new `mapping.xml`
178-
schema. In 7.0, this `mapping.xml` is stabilized and we now offer a transformation of `hbm.xml` files into `mapping.xml` files.
179-
180-
This tool is available as both:
181-
182-
* a build-time transformation (currently only offered as a Gradle plugin), or
183-
* a runtime transformation, using `hibernate.transform_hbm_xml.enabled=true`
184-
185-
Build-time transformation is preferred.
186-
187-
[NOTE]
188-
====
189-
Initial versions of the transformation processed one file at a time.
190-
This is now done across the entire set of `hbm.xml` files at once.
191-
While most users will never see this change, it might impact integrations which tie-in to XML processing.
192-
====
193-
194-
[[stateless-session-cache]]
195-
=== StatelessSession and Second Level Cache
196-
197-
Previously, stateless sessions never interacted with the second-level cache.
198-
This reflected their original intended role in bulk processing.
199-
With the advent of Jakarta Data and Hibernate Data Repositories, the responsibilities of `StatelessSession` have now expanded, and this behavior is no longer appropriate.
200-
201-
Thus, a stateless session now makes use of the second-level cache by default.
202-
To completely bypass the second-level cache, recovering the previous behavior, call `setCacheMode(CacheMode.IGNORE)`.
203-
204-
It's often important to explicitly disable puts to the second-level cache in code which performs bulk processing.
205-
Set the cache mode to `GET` or configure `jakarta.persistence.cache.storeMode` to `BYPASS`.
206-
207-
[[stateless-session-jdbc-batching]]
208-
=== StatelessSession and JDBC Batching
209-
210-
Automatic JDBC batching has the side effect of delaying the execution of the batched operation, and this undermines the synchronous nature of operations performed through a stateless session.
211-
In Hibernate 7, the configuration property `hibernate.jdbc.batch_size` now has no effect on a stateless session.
212-
Automatic batching may be enabled by explicitly calling `setJdbcBatchSize()`.
213-
However, the preferred approach is to explicitly batch operations via `insertMultiple()`, `updateMultiple()`, or `deleteMultiple()`.
106+
See the link:{releaseSeriesBase}#whats-new[website] for the list of new features in the 7.0 series.
214107

215-
[[session-find-multiple]]
216-
=== findMultiple()
217-
218-
The new operation `Session.findMultiple()`, along with the `BatchSize` option provides a convenient way to fetch a batch of entities by id.
219-
220-
[[session-managed-entities]]
221-
=== Direct access to first-level cache
222-
223-
The new operation `Session.getManagedEntities()` allows the application program to iterate over all entities in the first-level cache, or over all entities of a given type.
224-
225-
[[schema-manager-populate]]
226-
=== Data population
227-
228-
Setting `jakarta.persistence.schema-generation.database.action=populate` or calling `SchemaManager.populate()` populates an existing schema with initial data in `/import.sql` or other SQL scripts specified via `jakarta.persistence.sql-load-script-source`.
229-
230-
[[transaction-api]]
231-
=== Improvements to Transaction
232-
233-
The `Transaction` interface leaks the SPI type `TransactionStatus` via `getStatus()`, and the JTA-defined type `Synchronization` via `registerSynchronization()`, which breaks layering in a fairly harmless way.
234-
New operations were added to the `Transaction` interface, allowing code to inspect the status of the transaction or register callbacks without the use of layer-breaking operations.
235108

236109

237110
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -241,21 +114,27 @@ New operations were added to the `Transaction` interface, allowing code to inspe
241114
[[api-changes]]
242115
== Changes to API
243116

117+
This section describes changes to contracts (classes, interfaces, methods, etc.) which are consider https://hibernate.org/community/compatibility-policy/#api[API].
118+
119+
[[defer-to-jpa]]
120+
=== Defer to JPA
121+
244122
A general theme in 7.0 has been to remove Hibernate-specific features that have a direct replacement in JPA.
245123

246124
[[session-load]]
247-
=== Session#load
125+
==== Session#load
248126

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

129+
251130
[[session-get]]
252-
=== Session#get
131+
==== Session#get
253132
`Session#get` methods were deprecated in favor of the JPA-standard `Session#find`, and new overloads of `Session#find` were added.
254133

255134
NOTE: `Session#get` was not previously deprecated as `Session#load` was, so it was not appropriate to remove it.
256135

257136
[[session-refresh]]
258-
=== Session#refresh
137+
==== Session#refresh
259138

260139
The forms of `Session#refresh` accepting an entity-name have been removed; the passed entity already indicates the entity-name (even with dynamic models).
261140

@@ -265,7 +144,7 @@ The forms of `Session#refresh` accepting an entity-name have been removed; the p
265144
Removed in favor of `Session#refresh(Object object, LockOptions lockOptions)`
266145

267146
[[session-save-update]]
268-
=== Session#save, Session#update, Session#saveOrUpdate
147+
==== Session#save, Session#update, Session#saveOrUpdate
269148

270149
All forms of `Session#save`, `Session#update`, `Session#saveOrUpdate` have been removed. See the discussion at <<flush-persist>>.
271150

@@ -280,7 +159,7 @@ Relatedly, `org.hibernate.annotations.CascadeType#SAVE_UPDATE` has been removed
280159

281160

282161
[[session-delete]]
283-
=== Session#delete
162+
==== Session#delete
284163

285164
`Session#delete` methods has been removed in favor of `Session#remove`. Relatedly, `org.hibernate.annotations.CascadeType#DELETE` was removed in favor of `org.hibernate.annotations.CascadeType#REMOVE`{fn-cascase-type}
286165

@@ -346,13 +225,6 @@ All such cases though are already controllable by the application.
346225

347226
The effect can also often be mitigated using Hibernate's bytecode-based laziness (possibly combined with `@ConcreteProxy`).
348227

349-
[[usertype]]
350-
=== Changes to UserType and CompositeUserType
351-
352-
The API interfaces `UserType` and `CompositeUserType` leaked the SPI types `SharedSessionContractImplementor` and `SessionFactoryImplementor`, which was a layer-breaker.
353-
354-
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`.
355-
356228

357229
[[misc-api]]
358230
=== Miscellaneous
@@ -373,6 +245,8 @@ The solution was to change the signature of `nullSafeSet()` and `nullSafeGet()`
373245
[[spi-changes]]
374246
== Changes to SPI
375247

248+
This section describes changes to contracts (classes, interfaces, methods, etc.) which are consider https://hibernate.org/community/compatibility-policy/#spi[SPI].
249+
376250
[[configurable-generators]]
377251
=== Configurable generators
378252

@@ -401,13 +275,12 @@ Quite a few (again, previously deprecated) methods on `Interceptor` have been re
401275
Additionally, `EmptyInterceptor` was removed. As `org.hibernate.Interceptor` now uses default methods, one can simply implement `Interceptor` to the same end.
402276

403277

404-
[[misc-spi]]
405-
=== Miscellaneous
278+
[[usertype]]
279+
=== Changes to UserType and CompositeUserType
406280

407-
* `org.hibernate.metamodel.spi.MetamodelImplementor`
408-
was removed in favor of `org.hibernate.metamodel.MappingMetmodel` or `org.hibernate.metamodel.model.domain.JpaMetamodel`
409-
* Removed `AdditionalJaxbMappingProducer` in favor of `AdditionalMappingContributor`.
410-
* Removed `MetadataContributor` in favor of `AdditionalMappingContributor`
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`.
411284

412285
[[jfr-spi]]
413286
=== JFR SPI
@@ -416,6 +289,15 @@ The types `EventMonitor` and `DiagonosticEvent` replace the now-deprecated SPIs
416289

417290
Hibernate now reports many more kinds of `DiagnosticEvent` to JFR.
418291

292+
[[misc-spi]]
293+
=== Miscellaneous
294+
295+
* `org.hibernate.metamodel.spi.MetamodelImplementor`
296+
was removed in favor of `org.hibernate.metamodel.MappingMetmodel` or `org.hibernate.metamodel.model.domain.JpaMetamodel`
297+
* Removed `AdditionalJaxbMappingProducer` in favor of `AdditionalMappingContributor`.
298+
* Removed `MetadataContributor` in favor of `AdditionalMappingContributor`
299+
300+
419301

420302
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
421303
// Changes in Behavior
@@ -424,6 +306,7 @@ Hibernate now reports many more kinds of `DiagnosticEvent` to JFR.
424306
[[behavior-changes]]
425307
== Changes in Behavior
426308

309+
427310
[[model-validation]]
428311
=== Domain Model Validations
429312

@@ -506,6 +389,29 @@ This includes auto-applied converters.
506389
To suppress the error for an auto-applied converter, use `@Convert(disableConversion=true)`.
507390

508391

392+
[[stateless-session-behavior]]
393+
=== StatelessSession Behavior
394+
395+
The behavior of Hibernate's `StatelessSession` has changed in 2 specific ways to be aware of:
396+
397+
[[stateless-session-cache]]
398+
==== StatelessSession and Second-Level Cache
399+
400+
A stateless session now link:{releaseSeriesBase}#stateless-session-cache[makes use of the second-level cache] by default. This will affect migrating applications using second-level cache and `StatelessSession`.
401+
402+
To completely bypass the second-level cache, recovering the previous behavior, call `setCacheMode(CacheMode.IGNORE)`.
403+
404+
It's often important to explicitly disable puts to the second-level cache in code which performs bulk processing.
405+
Set the cache mode to `GET` or configure `jakarta.persistence.cache.storeMode` to `BYPASS`.
406+
407+
408+
[[stateless-session-jdbc-batching]]
409+
==== StatelessSession and JDBC Batching
410+
411+
The configuration property `hibernate.jdbc.batch_size` now has link:{releaseSeriesBase}#stateless-session-jdbc-batching[no effect on a StatelessSession].
412+
JDBC batching may be enabled by explicitly calling `setJdbcBatchSize()`.
413+
However, the preferred approach is to use the new link:{releaseSeriesBase}#stateless-session-multiple[explicit batch operations] via `insertMultiple()`, `updateMultiple()`, or `deleteMultiple()`.
414+
509415

510416
[[create-query]]
511417
=== Query with Implicit SELECT and No Explicit Result Type
@@ -521,7 +427,7 @@ or:
521427

522428
[source,java]
523429
List query =
524-
session.createQuery("from X join ys")
430+
session.createQuery("from X join y")
525431
.getResultList()
526432

527433
The select list was inferred based on the `from` clause.
@@ -550,12 +456,13 @@ or:
550456

551457
[source,java]
552458
List<X> result =
553-
session.createQuery("from X join ys", X.class)
459+
session.createQuery("from X join y", X.class)
554460
.getResultList()
555461

556462
[[flush-persist]]
557463
=== Session flush and persist
558464

465+
559466
The removal of `CascadeType.SAVE_UPDATE` slightly changes the persist and flush behaviour to conform with the Jakarta Persistence specification.
560467

561468
Making a transient entity persistent or flushing a managed entity now results in an `jakarta.persistence.EntityExistsException` if:
@@ -710,6 +617,8 @@ Starting in 7.0, when `ValidationMode#AUTO` is specified and a Bean Validation p
710617
[[ddl-changes]]
711618
== Changes Affecting DDL
712619

620+
This section describes changes which may affect the application's database schema.
621+
713622
[[ddl-implicit-datatype-timestamp]]
714623
=== Default Precision for timestamp
715624

@@ -762,9 +671,7 @@ Now, `varchar(1)` is used by default.
762671
[[pools]]
763672
== Connection Pools
764673

765-
Since Vibur and Proxool are no longer actively developed, support for these connection pools was removed.
766-
767-
As part of the effort to relicense Hibernate, it also became necessary to drop support for Oracle UCP connection pool.
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.
768675

769676
We recommend using https://github.com/agroal/agroal[Agroal] or https://github.com/brettwooldridge/HikariCP[HikariCP] instead.
770677
Alternatively, you may implement the `ConnectionProvider` interface to integrate the connection pool of your choice.

0 commit comments

Comments
 (0)