Speaking merely about dependencies, the upgrade from Hibernate 4.3.x to >= 5.2.x is pretty straight forward. The latest >= 5.2.x version is pretty solid and has been tested by the community for quite some time now. The more recent versions >= 5.3.x have been released in November 2020.
You can achieve the migration in your pom.xml
with the following snippets:
Hibernate 5.2.x
<properties>
<hibernate.version>5.2.18.Final</hibernate.version>
<hibernate.validator.version>6.0.21.Final</hibernate.validator.version>
<java-version>10</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
Hibernate 5.3.x
Just replace one property value to read:
<hibernate.version>5.3.22.Final</hibernate.version>
All other relevant transitive dependencies are pulled in via the above artifacts automatically.
Note well
The hibernate-entitymanager-...jar
which was used by your original pom.xml
snippet no longer exists in Hibernate 5.2.x. Everything which is related to JPA/EntityManager is now incorporated in hibernate-core-...jar
.
Hibernate Validator
Starting with the release of version 6.0.10, the library fully supports JDK10:
You can now build and use Hibernate Validator with JDK 10.
For reference see: http://in.relation.to/2018/05/15/hibernate-validator-6010-final-out/
Checks...
Moreover, review every persistence.xml
file in the project so that
you set: <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
and define the header to be JPA 2.1 compliant:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
or
3. to be JPA 2.2 compliant as
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
Further remarks
In theory, all important dependencies should be drawn into your project with the above snippets. However, in practice, you will (most likely) encounter some breaking changes at compile or runtime with your existing project code. Many of these can be resolved by checking the official migration guides here:
Hope it helps.