开放自由与休眠

Open liberty and Hibernate

我可以在 open-liberty 中使用 Hibernate 作为 JPA 实现吗?如果存在这样的集成,我会假设它带有分布式缓存和 JTA?

是的,在 OpenLiberty 中我们有 jpaContainer-2.1 功能,它只提供 JPA 容器集成代码,并允许用户插入自己的 JPA 2.1 兼容实现(即 EclipseLink 或 Hibernate)。

特别针对 Hibernate,jpaContainer-2.1 特性将 Hibernate 与 Liberty 的事务管理器集成。参见 LibertyJtaPlatform

您可以在此处找到完整的文档,包括配置示例:
Deploying a JPA application to Liberty

您在 server.xml 中需要的基本配置如下:

<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>