Jakarta Persistence Container3.13.02.22.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
Standard API packages provided by this feature
jakarta.persistence
jakarta.persistence.criteria
jakarta.persistence.metamodel
jakarta.persistence.spi