Java Persistence API Container
3.1
3.0
2.2
2.1

This feature enables support for applications that use application-managed and container-managed JPA. This feature only includes Java Persistence API 2.1 specification interfaces and container-managed JPA integration. This feature does not include a JPA provider implementation.

Enabling this feature

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

<feature>jpaContainer-2.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>jpaContainer-2.2</feature>
   <feature>bells-1.0</feature>
      ...
</featureManager>

<library id="HibernateLib">
    <fileset dir="${shared.resource.dir}/jpa21_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 element 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 parameter specifies the location of the application files. The classloader element adds any files and directories that are specified by the commonLibraryRef attribute to the application class path, which makes them available to the application.

Feature configuration elements

Standard API packages provided by this feature

  • javax.persistence

  • javax.persistence.criteria

  • javax.persistence.metamodel

  • javax.persistence.spi

Features that this feature enables

Supported Java versions

  • JavaSE-1.8

  • JavaSE-11.0

  • JavaSE-17.0

  • JavaSE-20.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.

com.ibm.websphere.appserver.jpaContainer-2.1; type="osgi.subsystem.feature"