Skip to content

Commit ca8d8b2

Browse files
committed
release details
1 parent 982ab4e commit ca8d8b2

File tree

2 files changed

+51
-227
lines changed

2 files changed

+51
-227
lines changed

Diff for: migration-guide.adoc

+49-139
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,138 +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 triggers Hibernate to use the column names `home_street`, `home_city`, `work_street`, ...
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
106+
See the link:{releaseSeriesBase}#whats-new[website] for the list of new features in the 7.0 series.
176107

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-
* build-time transformation (currently only offered as a Gradle plugin)
183-
* run-time 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()`.
214-
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`.
229108

230109

231110
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -235,17 +114,22 @@ Setting `jakarta.persistence.schema-generation.database.action=populate` or call
235114
[[api-changes]]
236115
== Changes to API
237116

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+
238122
A general theme in 7.0 has been to remove Hibernate-specific features that have a direct replacement in JPA.
239123

240124
[[session-load]]
241-
=== Session#load
125+
==== Session#load
242126

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

245129
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.
246130

247131
[[session-refresh]]
248-
=== Session#refresh
132+
==== Session#refresh
249133

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

@@ -255,7 +139,7 @@ The forms of `Session#refresh` accepting an entity-name have been removed; the p
255139
Removed in favor of `Session#refresh(Object object, LockOptions lockOptions)`
256140

257141
[[session-save-update]]
258-
=== Session#save, Session#update, Session#saveOrUpdate
142+
==== Session#save, Session#update, Session#saveOrUpdate
259143

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

@@ -270,7 +154,7 @@ Relatedly, `org.hibernate.annotations.CascadeType#SAVE_UPDATE` has been removed
270154

271155

272156
[[session-delete]]
273-
=== Session#delete
157+
==== Session#delete
274158

275159
`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}
276160

@@ -354,6 +238,8 @@ The effect can also often be mitigated using Hibernate's bytecode-based laziness
354238
[[spi-changes]]
355239
== Changes to SPI
356240

241+
This section describes changes to contracts (classes, interfaces, methods, etc.) which are consider https://hibernate.org/community/compatibility-policy/#spi[SPI].
242+
357243
[[configurable-generators]]
358244
=== Configurable generators
359245

@@ -399,6 +285,7 @@ was removed in favor of `org.hibernate.metamodel.MappingMetmodel` or `org.hibern
399285
[[behavior-changes]]
400286
== Changes in Behavior
401287

288+
402289
[[model-validation]]
403290
=== Domain Model Validations
404291

@@ -481,6 +368,29 @@ This includes auto-applied converters.
481368
To suppress the error for an auto-applied converter, use `@Convert(disableConversion=true)`.
482369

483370

371+
[[stateless-session-behavior]]
372+
=== StatelessSession Behavior
373+
374+
The behavior of Hibernate's `StatelessSession` has changed in 2 specific ways to be aware of:
375+
376+
[[stateless-session-cache]]
377+
==== StatelessSession and Second-Level Cache
378+
379+
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`.
380+
381+
To completely bypass the second-level cache, recovering the previous behavior, call `setCacheMode(CacheMode.IGNORE)`.
382+
383+
It's often important to explicitly disable puts to the second-level cache in code which performs bulk processing.
384+
Set the cache mode to `GET` or configure `jakarta.persistence.cache.storeMode` to `BYPASS`.
385+
386+
387+
[[stateless-session-jdbc-batching]]
388+
==== StatelessSession and JDBC Batching
389+
390+
The configuration property `hibernate.jdbc.batch_size` now has link:{releaseSeriesBase}#stateless-session-jdbc-batching[no effect on a StatelessSession].
391+
JDBC batching may be enabled by explicitly calling `setJdbcBatchSize()`.
392+
However, the preferred approach is to use the new link:{releaseSeriesBase}#stateless-session-multiple[explicit batch operations] via `insertMultiple()`, `updateMultiple()`, or `deleteMultiple()`.
393+
484394

485395
[[create-query]]
486396
=== Query with Implicit SELECT and No Explicit Result Type
@@ -680,6 +590,8 @@ Starting in 7.0, when `ValidationMode#AUTO` is specified and a Bean Validation p
680590
[[ddl-changes]]
681591
== Changes Affecting DDL
682592

593+
This section describes changes which may affect the application's database schema.
594+
683595
[[ddl-implicit-datatype-timestamp]]
684596
=== Default Precision for timestamp
685597

@@ -732,9 +644,7 @@ Now, `varchar(1)` is used by default.
732644
[[pools]]
733645
== Connection Pools
734646

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

739649
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).
740650

Diff for: release_notes.md

+2-88
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,3 @@
11

2-
### <a name="jpa-32"></a> Jakarta Persistence 3.2
3-
4-
7.0 migrates to Jakarta Persistence 3.2 which can be fairly disruptive.
5-
See the [Migration Guide](https://docs.jboss.org/hibernate/orm/7.0/migration-guide/migration-guide.html#jpa-32) for details.
6-
7-
See [this blog post](https://in.relation.to/2024/04/01/jakarta-persistence-3/) for a summary of the changes in 3.2
8-
9-
- [TCK Results](https://ci.hibernate.org/view/ORM/job/hibernate-orm-tck-3.2/job/wip%252F7.0/24/) with Java 17
10-
- [TCK Results](https://ci.hibernate.org/view/ORM/job/hibernate-orm-tck-3.2/job/wip%252F7.0/25/) with Java 21
11-
12-
### <a name="java-17"></a> Java 17
13-
14-
Version 3.2 of Jakarta Persistence requires Java 17.
15-
Hibernate 7.0 therefore baselines on Java 17 whereas previous versions baseline on Java 11.
16-
17-
### <a name="model-validations"></a> Domain Model Validations
18-
19-
7.0 does much more validation of an application's domain model and especially its mapping details, e.g.
20-
21-
* illegal combinations such as `@Basic` and `@ManyToOne` on the same attribute
22-
* misplaced annotations such as an annotated getter method with FIELD access
23-
* stricter following of JavaBean conventions
24-
25-
See the [Migration Guide](https://docs.jboss.org/hibernate/orm/7.0/migration-guide/migration-guide.html#model-validation) for details.
26-
27-
28-
### <a name="mapping-xml"></a> mapping.xsd
29-
30-
Hibernate 7.0 provides a new XSD that represents an "extension" of the Jakarta Persistence orm.xsd weaving in Hibernate-specific mapping features.
31-
The namespace for this extended mapping is `http://www.hibernate.org/xsd/orm/mapping`
32-
33-
For applications using Hibernate's legacy `hbm.xml` format, we provide a tool to help with the transformation.
34-
See the [Migration Guide](https://docs.jboss.org/hibernate/orm/7.0/migration-guide/migration-guide.html#hbm-transform) for details.
35-
36-
37-
### <a name="hibernate-models"></a> Hibernate Models
38-
39-
7.0 migrates from [Hibernate Commons Annotations](https://github.com/hibernate/hibernate-commons-annotations/) (HCANN) to the new [Hibernate Models](https://github.com/hibernate/hibernate-models) project for low-level processing of an application domain model, reading annotations and weaving in XML mapping documents.
40-
See the [Migration Guide](https://docs.jboss.org/hibernate/orm/7.0/migration-guide/migration-guide.html#hibernate-models) for details.
41-
42-
43-
### <a name="json-and-xml-functions"></a> JSON and XML functions
44-
45-
Support for most of the JSON and XML functions that the SQL standard specifies was added to HQL/Criteria.
46-
The implementations retain the SQL standard semantics and will throw an error if emulation on a database is impossible.
47-
48-
New functions include:
49-
50-
* construction functions like `json_array()`, `json_object()`, `xmlelement()` and `xmlforest()`
51-
* query functions like `json_value()`, `json_query()` and `xmlquery()`
52-
* aggregation functions like `json_agg()`, `json_object_agg()` and `xmlagg()`
53-
* manipulation functions like `json_set()`, `json_mergepatch()`
54-
* any many more
55-
56-
> The functions are incubating/tech-preview - to use them in HQL it is necessary to enable the `hibernate.query.hql.json_functions_enabled` and `hibernate.query.hql.xml_functions_enabled` configuration settings.
57-
58-
59-
### <a name="set-returning-functions"></a> Set-returning Functions
60-
61-
A set-returning function is a new type of function that can return rows and is exclusive to the `from` clause.
62-
The concept is known in many different database SQL dialects and is sometimes referred to as table valued function or table function.
63-
64-
Custom set-returning functions can be registered via a `FunctionContributor`.
65-
Out-of-the-box, some common set-returning functions are already supported or emulated
66-
67-
* `unnest()` - allows to turn an array into rows
68-
* `generate_series()` - can be used to create a series of values as rows
69-
* `json_table()` - turns a JSON document into rows
70-
* `xmltable()` - turns an XML document into rows
71-
72-
### <a name="any-discriminator"></a> @AnyDiscriminatorImplicitValues
73-
74-
The new `@AnyDiscriminatorImplicitValues` offers 2 related improvements for the mapping of discriminator values
75-
for `@Any` and `ManyToAny` associations.
76-
77-
First, it allows control over how Hibernate determines the discriminator value to store in the database for
78-
implicit discriminator mappings. Historically, Hibernate would always use the full name of the associated
79-
entity.
80-
81-
Second, it allows mixing of explicit and implicit value strategies.
82-
83-
See the [Migration Guide](https://docs.jboss.org/hibernate/orm/7.0/userguide/html_single/Hibernate_User_Guide.html#associations-any) for details.
84-
85-
### <a name=cleanup"></a> Clean-up
86-
87-
A lot of deprecated contracts and behavior has been removed.
88-
See the [Migration Guide](https://docs.jboss.org/hibernate/orm/7.0/migration-guide/migration-guide.html#cleanup) for details.
89-
2+
* See the [website](https://hibernate.org.orm/releases/7.0) for requirements and new features in 7.0.
3+
* See the [Migration Guide](https://docs.jboss.org/hibernate/orm/7.0/migration-guide/migration-guide.html) for details about migration from version 6.6 to 7.0.

0 commit comments

Comments
 (0)