Over a million developers have joined DZone.

Migrate the Hibernate Second-Level Caching With Hazelcast in Java 10

DZone 's Guide to

Migrate the Hibernate Second-Level Caching With Hazelcast in Java 10

Click here to learn how to migrate the Hibernate second-level catching tool with the Hazelcast in Java 10.

· Java Zone ·
Free Resource

Technologies in any industry changes over time. The same goes for Java technologies. Recently, Oracle launched Java 10 on March 20, 2018. It was a paradigm shift in the Java project structure. Oracle Java has restructured all of its jar into different modules, i.e java.base, etc. Now, the module of a project can become modular in terms of JDK, as well. A certain number of packages are removed from JDK 10 i.e java.xml.binding. This means that the projects that get compiled and ran in older JDK will not get compiled in JDK 10. But, Oracle Java has provided features by which projects written in older JDK can be compiled and ran in JDK 10. For this reason, the project that is dependent on different frameworks or tools, which are not migrated to JDK 10, will not get compiled.

I have done the migration of project with the Hibernate second-level caching tool in Hazelcast to JDK 10 and executed some test cases to ensure it works properly. 

The maven-surefire-plugin of pom file of the project should be changed as follows: 


As I said earlier, java.xml.bind is being removed from JDK 10. So, the Hibernate project will not be compiled in JDK 10. In above code snippet, the tag <argLine> contains the additional arguments for the execution of JUnit 5 test cases successfully in JDK 10. 

The following dependency is required for Hibernate and Hazelcast configuration for caching

<!-- Hibernate Core -->

<!-- Hazelcast -->

Any other combination of Hibernate and Hazelcast versions may not compile or run properly for the project in JDK 10. So, by making the above changes in pom file for Hibernate with Hazelcast as caching in the project written in the older JDK, it will make the compilation and execution successful in JDK 10.

The source code is available at: https://github.com/aloktech/MigrateHibernateToJava10/tree/master/HibernateHazelcastCache.

java 10 ,hibernate caching ,hazelcast ,maven 3.5.0 ,java ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}