Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open liberty and Hibernate

Can I use Hibernate as JPA implementation in open-liberty? If such integration exists, I would presume that it comes with distributed caching and JTA?

like image 701
Hristo Stoyanov Avatar asked Nov 20 '17 16:11

Hristo Stoyanov


1 Answers

Yes, in OpenLiberty we have the jpaContainer-2.1 feature, which provides only the JPA container integration code, and allows the user to plug in their own JPA 2.1 compliant implementation (i.e. EclipseLink or Hibernate).

Specifically for Hibernate, the jpaContainer-2.1 feature will integrate Hibernate with Liberty's transaction manager. See LibertyJtaPlatform

You can find full documentation here, including config examples:
Deploying a JPA application to Liberty

The basic config you will need in server.xml is the following:

<featureManager>
   <feature>jpaContainer-2.1</feature>
   <feature>bells-1.0</feature>
      ...    
</featureManager>    

<!-- Making a 'bell' for the library will register any META-INF/services in the referenced library with the Liberty runtime -->
<bell libraryRef="hibernate"/>

<!-- Include all of the hibernate jars in a shared lib -->
<library id="hibernate">
    <fileset dir="${server.config.dir}/hibernate/" includes="*.jar"/>
</library>

<!-- OPTIONAL: If you wish to directly reference hibernate APIs in your app, you will need to configure a shared library classloader -->
<application location="myApp.war">
   <classloader commonLibraryRef="hibernate"/>
</application>
like image 197
Andy Guibert Avatar answered Dec 05 '22 17:12

Andy Guibert