2023-11-01 18:37:38 -04:00
|
|
|
= 7.0 Migration Guide
|
2015-08-20 15:29:48 -04:00
|
|
|
:toc:
|
2022-01-05 17:24:11 -05:00
|
|
|
:toclevels: 4
|
2022-12-22 11:29:51 -05:00
|
|
|
:docsBase: https://docs.jboss.org/hibernate/orm
|
2024-03-26 21:31:09 -04:00
|
|
|
:versionDocBase: {docsBase}/7.0
|
2022-12-22 11:29:51 -05:00
|
|
|
:userGuideBase: {versionDocBase}/userguide/html_single/Hibernate_User_Guide.html
|
|
|
|
:javadocsBase: {versionDocBase}/javadocs
|
2022-01-05 17:24:11 -05:00
|
|
|
|
2023-11-01 18:37:38 -04:00
|
|
|
|
|
|
|
This guide discusses migration to Hibernate ORM version 7.0. For migration from
|
2015-08-20 15:29:48 -04:00
|
|
|
earlier versions, see any other pertinent migration guides as well.
|
|
|
|
|
2023-11-01 18:37:38 -04:00
|
|
|
[[jpa-32]]
|
|
|
|
== JPA 3.2
|
|
|
|
|
|
|
|
7.0 migrates to JPA 3.2 which is fairly disruptive, mainly around:
|
|
|
|
|
|
|
|
* type parameters
|
2023-11-02 13:54:36 -04:00
|
|
|
** Affects much of the Criteria API - especially roots, joins, paths
|
|
|
|
** Affects much of the Graph API -
|
|
|
|
*** org.hibernate.graph.Graph.addAttributeNode(java.lang.String) defines a return while
|
2023-11-01 20:40:31 -04:00
|
|
|
1jakarta.persistence.Graph.addAttributeNode(java.lang.String)` does not.
|
2023-11-01 18:37:38 -04:00
|
|
|
* new JPA features colliding with previous Hibernate extension features
|
2023-11-02 13:54:36 -04:00
|
|
|
** `Nulls` (JPA) v. `NullPrecedence` (Hibernate), including JPA's new `Order#getNullPrecedence()` returning `Nulls`
|
2023-11-01 18:37:38 -04:00
|
|
|
colliding with Hibernate's `SqmSortSpecification#getNullPrecedence` returning `NullPrecedence`. Hibernate's form
|
|
|
|
was renamed to `SqmSortSpecification#getHibernateNullPrecedence` to avoid the collision.
|
2023-11-02 13:54:36 -04:00
|
|
|
** `SchemaManager` is now also a JPA contract exposed as `EntityManagerFactory#getSchemaManager` which leads to type issues for
|
2023-11-01 18:37:38 -04:00
|
|
|
Hibernate's `SessionFactory#getSchemaManager`. Hibernate's `SchemaManager` now extends the new JPA `SchemaManager`.
|
|
|
|
But that is a bytecode incompatibility.
|
2023-11-02 13:54:36 -04:00
|
|
|
** JPA has added support in its Graph API for things Hibernate has supported for some time. Some of those are collisions
|
2023-11-01 18:37:38 -04:00
|
|
|
requiring changes to the Hibernate API.
|
2022-12-22 11:29:51 -05:00
|
|
|
|
2024-01-03 10:59:39 -05:00
|
|
|
[[annotation-validation]]
|
|
|
|
== Annotation Validations
|
|
|
|
|
|
|
|
7.0 adds many more checks about illegal use of annotations.
|
|
|
|
|
|
|
|
=== Access
|
|
|
|
|
|
|
|
The Jakarta Persistence specification says that it is illegal to specify `@Access(FIELD)` on a property (getter)
|
|
|
|
or to use `@Access(PROPERTY)` on a field. As of 7.0, Hibernate now throws an exception when this condition is
|
|
|
|
discovered.
|
|
|
|
|
|
|
|
=== PersistentAttributeType
|
|
|
|
|
|
|
|
As of 7.0, Hibernate applies much better validation of an attribute specifying multiple PersistentAttributeTypes.
|
|
|
|
Jakarta Persistence 3.2 has clarified this in the specification. E.g., the following examples are all now illegal -
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
----
|
|
|
|
@Basic
|
|
|
|
@ManyToOne
|
|
|
|
private Employee manager;
|
|
|
|
----
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
----
|
|
|
|
@Lob
|
|
|
|
@ManyToOne
|
|
|
|
private Employee manager;
|
|
|
|
----
|
|
|
|
|
2024-05-03 12:18:57 -04:00
|
|
|
|
2023-11-02 00:01:23 -04:00
|
|
|
[[cleanup]]
|
|
|
|
== Some Cleanup
|
2024-05-03 12:18:57 -04:00
|
|
|
|
2023-11-02 00:01:23 -04:00
|
|
|
* Removed `SqmQualifiedJoin`. All joins are qualified.
|
2024-03-26 21:31:09 -04:00
|
|
|
* Removed `AdditionalJaxbMappingProducer`, deprecated in favor of `AdditionalMappingContributor`
|
|
|
|
* Removed `MetadataContributor`, deprecated in favor of `AdditionalMappingContributor`
|
2024-05-03 12:18:57 -04:00
|
|
|
|
|
|
|
|
2023-11-02 00:01:23 -04:00
|
|
|
[[todo]]
|
|
|
|
== Todos
|
2024-05-03 12:18:57 -04:00
|
|
|
|
2023-11-02 00:01:23 -04:00
|
|
|
NOTE:: Look for `// todo (jpa 3.2)`
|
2024-05-03 12:18:57 -04:00
|
|
|
|
2023-11-02 00:01:23 -04:00
|
|
|
* {@linkplain SqmCrossJoin} and its offspring are largely de-typed to account
|
|
|
|
for {@linkplain SqmCrossJoin} having only one type argument for the right-hand
|
|
|
|
side. To properly handle the type parameters in the hierarchy we need to change this to
|
|
|
|
accept type parameter for the left-handle side as well - breaking change.
|
|
|
|
* The changes in `jakarta.persistence.EntityManager#createNativeQuery(java.lang.String, java.lang.Class<?>)` are really unfortunate.
|
|
|
|
Previously that signature was `(java.lang.String, java.lang.Class)` and our override of that was able to be
|
|
|
|
`<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass)`. JPA adding that wildcard means our
|
|
|
|
override is no longer valid. I had to change that to ``
|