Java Persistence API Container3.13.02.22.1
This feature enables support for applications that use application-managed and container-managed JPA. This feature only includes Java Persistence API 2.2 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.2 feature, add the following element declaration into your server.xml
file, inside the featureManager
element:
<feature>jpaContainer-2.2</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
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.
Standard API packages provided by this feature
javax.activation
javax.persistence
javax.persistence.criteria
javax.persistence.metamodel
javax.persistence.spi
javax.xml.bind
javax.xml.bind.annotation
javax.xml.bind.annotation.adapters
javax.xml.bind.attachment
javax.xml.bind.helpers
javax.xml.bind.util