Skip to content

Commit 903ce66

Browse files
committed
mention org.hibernate.graph in migration guide
1 parent 3e36bc4 commit 903ce66

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

migration-guide.adoc

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ earlier versions, see any other pertinent migration guides as well.
1515

1616
7.0 migrates to Jakarta Persistence 3.2 which is fairly disruptive, mainly around:
1717

18-
* type parameters
18+
* Type parameters:
1919
** Affects much of the Criteria API - especially roots, joins, paths
2020
** 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
2222
`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:
2424
** `Nulls` (JPA) v. `NullPrecedence` (Hibernate), including JPA's new `Order#getNullPrecedence()` returning `Nulls`
2525
colliding with Hibernate's `SqmSortSpecification#getNullPrecedence` returning `NullPrecedence`. Hibernate's form
2626
was renamed to `SqmSortSpecification#getHibernateNullPrecedence` to avoid the collision.
@@ -86,18 +86,19 @@ private Employee manager;
8686
=== Misplaced Annotations
8787

8888
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.
9090

91+
For example, this code now results in an error:
9192

9293
[source,java]
9394
----
9495
@Entity
9596
class Book {
96-
// defines FIELD access-type
97+
// specifies FIELD access, properties should not be annotated
9798
@Id
9899
Integer id;
99100
100-
// previously ignored, this is an error now
101+
// previously ignored, this is an error now
101102
@Column(name="category")
102103
String getType() { ... }
103104
}
@@ -114,7 +115,8 @@ versions did not validate this particularly well.
114115
[[java-beans]]
115116
=== JavaBean Conventions
116117

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:
118120

119121
[source,java]
120122
----
@@ -204,16 +206,16 @@ Applications will need to replace usages of the removed `@Proxy` annotation.
204206

205207
`@Proxy#proxyClass` has no direct replacement, but was also never needed/useful.
206208

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.
208210
By default (true), Hibernate would proxy an entity when possible and when asked for.
209211
"Asked for" includes calls to `Session#getReference` and lazy associations.
210212
All such cases though are already controllable by the application.
211213

212214
* 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`.
217219

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

@@ -310,8 +312,8 @@ The previous behavior may be recovered by setting `hibernate.query.native.prefer
310312
[[ddl-implicit-datatype-timestamp]]
311313
== Default precision for `timestamp` on some databases
312314

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

316318
Note that these changes only affect DDL generation.
317319

@@ -339,12 +341,12 @@ The migration requires to read data and re-save it.
339341
To retain backwards compatibility, configure the setting `hibernate.type.preferred_array_jdbc_type` to `VARBINARY`.
340342

341343
[[xml-format-mapper-changes]]
342-
== XML FormatMapper changes
344+
== XML `FormatMapper` changes
343345

344346
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.
346348

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.
348350
This change is necessary to allow mapping basic arrays as `SqlTypes.XML_ARRAY`.
349351

350352
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
365367

366368
However, because `hibernate.session_factory_name` is also a trigger to attempt to bind the SessionFactory into JNDI,
367369
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.
369371

370372
To work around this we have introduced a new `hibernate.session_factory_jndi_name` setting that can be used to explicitly
371373
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.
461463
This includes auto-applied converters.
462464
To suppress the error for an auto-applied converter, use `@Convert(disableConversion=true)`.
463465

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+
464479
== Deprecations
465480

466481
* `@Comment` is deprecated in favor of the JPA 3.2 `comment` members

0 commit comments

Comments
 (0)