开放自由和休眠

Hri*_*nov 5 hibernate jpa open-liberty

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

And*_*ert 7

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

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

您可以在此处找到完整的文档,包括配置示例:
将 JPA 应用程序部署到 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>
Run Code Online (Sandbox Code Playgroud)