2020-04-01 14:47:41 -04:00
= 6.0 Migration Guide
2015-08-20 15:29:48 -04:00
:toc:
2020-04-01 14:47:41 -04:00
This guide discusses migration from Hibernate ORM version 6.0. For migration from
2015-08-20 15:29:48 -04:00
earlier versions, see any other pertinent migration guides as well.
2016-05-03 13:21:11 -04:00
== Background
2018-01-17 23:02:35 -05:00
== Known changes
2021-09-23 17:34:44 -04:00
=== Jakarta Persistence
6.0 moves from Java Persistence as defined by the Java EE specs to
Jakarta Persistence as defined by the Jakarta EE spec. The most immediate
impact of this change is that applications would need to be updated to use
the Jakarata Persistence classes (`jakarta.persistence.*`) instead of the Java
Persistence ones (`javax.persistence.*`).
The Jakarta spec also renames the JPA settings (again, from `javax.persistence.*` to
'jakarta.persistence.*') and defines a new set of XSD namespaces for `orm.xml` and
`persistence.xml` files.
Jakarta provides a https://github.com/eclipse/transformer[transformer]
tool which, along with appropriate "rules", will transform a project from Java Persistence to
Jakarta Persistence. This can update package names in source, settings, xsd references and more.
// todo (6.0) : reference to `${root}/rules ?
NOTE: As far as the XSD and setting changes, Hibernate does support both sets as a temporary aid
in migration. It logs a deprecation warning when the Java EE variants are used.
=== Reading from JDBC
Read-by-position rather than read-by-name
2020-04-01 14:47:41 -04:00
=== Type system / custom types
2018-11-14 11:14:30 -05:00
2021-10-06 10:51:57 -04:00
==== Type changes
* The default type for `Duration` was changed to `NUMERIC` which could lead to schema validation errors
2021-09-23 17:34:44 -04:00
==== Influencing JdbcTypeDescriptor to use
2020-04-15 09:03:21 -04:00
2021-03-23 16:41:58 -04:00
Discuss `JdbcTypeCode`, `JdbcType`, `JdbcTypeRegistration`
2020-04-15 09:03:21 -04:00
==== Influencing JavaTypeDescriptor to use
Discuss `@JavaType`, `@JavaTypeRegistration`
2018-11-14 11:14:30 -05:00
2021-08-24 12:59:58 -04:00
==== Component Mapping
Multiple component mappings for the same java class with different property mappings is not supported anymore. Every property mapping combination should have its own java class"
2021-09-28 02:15:07 -04:00
=== Procedure Parameters, enable passing nulls
Passing null or not is now triggered by whether setting the parameter was called at all. In other ords a distinction is made between calling `setParameter` passing null versus not calling `setParameter` at all. In the first case, we pass along the null value; in the second we do not.
2021-08-24 12:59:58 -04:00
2021-10-01 16:15:23 -04:00
=== Native Query
==== Native query as a function call is no longer supported.
Given the `NamedNativeQuery`
```
@NamedNativeQuery(
name = "fn_person_and_phones",
query = "{ ? = call fn_person_and_phones( ? ) }",
callable = true,
resultSetMapping = "person_with_phones"
)
```
the code
```
scope.inTransaction(
entityManager -> {
try {
List<Object[]> postAndComments = entityManager.createNamedQuery("fn_person_and_phones" ).setParameter( 1, 1L ).getResultList();
```
is going to throw an `IllegalArgumentException`.
The migration code is
```
List<Object[]> postAndComments = entityManager.createStoredProcedureQuery( "fn_person_and_phones", "person_with_phones" ).setParameter( 1, 1L ).getResultList();
```
2020-04-01 14:47:41 -04:00
=== SQM
2018-11-14 11:14:30 -05:00
2020-04-01 14:47:41 -04:00
* Functions
* Multi-table bulk manipulation HQL/Criteria query handling
2018-11-14 11:14:30 -05:00
2021-09-27 14:19:54 -04:00
2021-11-17 08:52:52 -05:00
=== Removals
2021-09-27 14:19:54 -04:00
* JMX integration
* JACC integration
2021-11-17 08:52:52 -05:00
* @Deprecated features:
** 'hibernate.classLoader.application', 'hibernate.classLoader.resources', 'hibernate.classLoader.hibernate' and 'hibernate.classLoader.environment': use 'hibernate.classLoaders' instead.
** 'hibernate.hbm2dll.create_namespaces': use 'jakarta.persistence.create-database-schemas' or 'hibernate.hbm2ddl.create_namespaces'