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.0 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.0 Container feature, add the following element declaration into your server.xml
file, inside the featureManager
element:
<feature>persistenceContainer-3.0</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
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.
Standard API packages provided by this feature
jakarta.persistence
jakarta.persistence.criteria
jakarta.persistence.metamodel
jakarta.persistence.spi