Jakarta Persistence Container
3.1
3.0
2.2
2.1

This feature enables support for applications that use application-managed and container-managed persistence. This feature only includes Jakarta Persistence 3.1 specification interfaces and container-managed persistence integration. This feature does not include a Jakarta Persistence provider implementation.

Enabling this feature

To enable the Jakarta Persistence 3.1 Container feature, add the following element declaration into your server.xml file, inside the featureManager element:

<feature>persistenceContainer-3.1</feature>

Examples

Configure an alternative JPA implementation

EclipseLink is the default JPA implementation for Open Liberty. To use a different implementation, you must configure a shared library for the alternative JPA persistence provider and make that library available to any applications that need to use it. In addition to the JPA Container feature, you must also enable the Basic Extensions using Liberty Libraries feature to give the Open Liberty server access to the shared library.

In the following example, Hibernate is specified as the JPA implementation for an application that is named myApp:

<featureManager>
   <feature>persistenceContainer-3.0</feature>
   <feature>bells-1.0</feature>
      ...
</featureManager>

<library id="HibernateLib">
    <fileset dir="${shared.resource.dir}/jpa30_hibernate" includes="*.jar"/>
</library>

<bell libraryRef="HibernateLib"/>

<application location="myApp.war">
   <classloader commonLibraryRef="HibernateLib"/>
</application>

The library element specifies a shared library that is made available to both the server and the application. The fileset subelement specifies the base directory to search for files and the file patterns to include in search results. In this example, any files in the ${shared.resource.dir}/jpa21_hibernate directory with the .jar extension are included in search results.

The bell element enables Hibernate to register as the default persistence provider for the Open Liberty runtime.

To directly reference Hibernate APIs in your application, you must configure a shared library classloader within the application element. The location attribute specifies the location of the application files. The classloader subelement adds any files and directories that are specified by the commonLibraryRef attribute to the application class path, which makes them available to the application. For more information about shared libraries, see Class loader configuration.

Note: If your application uses CDI and you want to configure Hibernate as your JPA implementation, you must set the following property in your jvm.options file to enable the required ExtendedBeanManager interface:

-Dcom.ibm.websphere.jpa.hibernate-cdi-compatibility=true

Feature configuration elements

Standard API packages provided by this feature

  • jakarta.persistence

  • jakarta.persistence.criteria

  • jakarta.persistence.metamodel

  • jakarta.persistence.spi

Features that this feature enables

Supported Java versions

  • JavaSE-11.0

  • JavaSE-17.0

  • JavaSE-21.0

  • JavaSE-23.0

Platform Versions

  • jakartaee-10.0

Features that enable this feature

Developing a feature that depends on this feature

If you are developing a feature that depends on this feature, include the following item in the Subsystem-Content header in your feature manifest file.

io.openliberty.persistenceContainer-3.1; type="osgi.subsystem.feature"