2016-04-19 14:14:02 -04:00
|
|
|
= 6.0 Migration Guide
|
2015-08-20 15:29:48 -04:00
|
|
|
:toc:
|
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
This guide discusses migration from Hibernate ORM version 5.1 to 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-04-19 14:14:02 -04:00
|
|
|
== Move to Java 8 for baseline
|
2015-08-20 15:29:48 -04:00
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
Hibernate 6.0 is built using Java 8 JDK and will require Java 8 JRE at runtime (we are investigating whether
|
|
|
|
Java 9 will also work). This has a number of implications:
|
2015-08-20 15:29:48 -04:00
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
* The hibernate-java8 module has been merged into hibernate-core and the Java 8 date/time types are now natively
|
|
|
|
supported.
|
|
|
|
* (todo) support for Java 8 Optional
|
|
|
|
* (todo) support for other Java 8 features?
|
2015-08-20 15:29:48 -04:00
|
|
|
|
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
== hibernate-entitymanager merged into hibernate-core
|
2015-08-20 15:29:48 -04:00
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
The hibernate-entitymanager module has also been merged into hibernate-core.
|
2015-08-20 15:29:48 -04:00
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
* `org.hibernate.SessionFactory` now extends `javax.persistence.EntityManagerFactory` - temporarily it
|
|
|
|
technically extends `org.hibernate.jpa.HibernateEntityManagerFactory` (which in turn extends
|
|
|
|
`javax.persistence.EntityManagerFactory`) for backwards compatibility. `HibernateEntityManagerFactory`
|
|
|
|
is deprecated.
|
|
|
|
* `org.hibernate.Session` now extends `javax.persistence.EntityManager` - temporarily it
|
|
|
|
technically extends `org.hibernate.jpa.HibernateEntityManager` (which in turn extends
|
|
|
|
`javax.persistence.EntityManager`) for backwards compatibility. `HibernateEntityManager` is deprecated.
|
|
|
|
* Persister/type access is now exposed through `org.hibernate.Metamodel`, which extends
|
|
|
|
`javax.persistence.metamodel.Metamodel`. MetamodelImpl now manages all aspects of type system (see below).
|
|
|
|
* Cache management has also been consolidated. `org.hibernate.Cache` now extends `javax.persistence.Cache`. CacheImpl
|
|
|
|
now manages all aspects of cache regions (see below).
|
2015-08-20 15:29:48 -04:00
|
|
|
|
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
== SessionFactory hierarchy cleanup
|
2015-08-20 15:29:48 -04:00
|
|
|
|
2016-04-19 14:14:02 -04:00
|
|
|
As part of merging hibernate-entitymanager into hibernate-core, I also wanted to take a moment to clean up
|
|
|
|
some of these very old contracts, In conjunction with the move to Java 8 (default methods) and needing to
|
|
|
|
implement JPA methods now in core I decided to implement more of a composition approach here, thus:
|
|
|
|
|
|
|
|
* SessionFactoryImplementor used to have a number of methods pertaining to managing and accessing entity and collection persisters.
|
|
|
|
Since we need to deal with JPA Metamodel contract anyway, I went ahead and moved all of that code into our new
|
|
|
|
`org.hibernate.metamodel.spi.MetamodelImplementor`
|
|
|
|
* SessionFactory and SessionFactoryImplementor each had a number of methods dealing with cache regions.
|
|
|
|
Many of these methods have been deprecated since 5.0 and those will be removed. However, the functionality
|
|
|
|
has been moved into the `org.hibernate.Cache` and `org.hibernate.engine.spi.CacheImplementor` contracts
|
|
|
|
helping implement JPA's `javax.persistence.Cache` role.
|
|
|
|
|
|
|
|
== SQM
|
|
|
|
|
|
|
|
todo - discuss
|
|
|
|
|
|
|
|
|
|
|
|
== Misc
|
|
|
|
|
|
|
|
* QueryCacheFactory contract changed
|
|
|
|
* RegionFactory contract changes
|
|
|
|
* todo : merge AvailableSettings together
|
|
|
|
* org.hibernate.Transaction now extends JPA's EntityTransaction and follows its pre- and post- assertions.
|
|
|
|
e.g. begin() now throws an exception if transaction is already active.
|
|
|
|
* (todo) following the above one, JPA also says that only PersistenceUnitTransactionType#JTA EntiytManagers
|
|
|
|
are allowed to access EntityTransactions. Need a strategy to handle this
|
|
|
|
* Session#getFlushMode and Query#getFlushMode clash in terms of Hibernate (FlushMode) and JPA (FlushModeType)
|
|
|
|
returns. #getFlushMode has been altered to return JPA's FlushModeType. The Hibernate FlushMode
|
|
|
|
is still available via #getHibernateFlushMode and #setHibernateFlushMode
|