7 Configuring the Persistence Provider in Oracle WebLogic Server
This chapter includes the following sections:
Overview of Oracle TopLink
Oracle TopLink is the default persistence provider in WebLogic Server 12c and later. It is a comprehensive standards-based object-persistence and object-transformation framework that provides APIs, schemas, and run-time services for the persistence layer of an application.
The core component of TopLink is the EclipseLink project's produced libraries and utilities. EclipseLink is the open source implementation of the development framework and the runtime provided in TopLink. EclipseLink implements the following specifications, plus value-added extensions:
-
Jakarta Persistence (JPA)
For the complete JPA specification, see
https://jakarta.ee/specifications/persistence/. -
Jakarta XML Binding (JAXB). The EclipseLink JAXB implementation, plus EclipseLink extensions, is called MOXy.
For the JAXB specification, see
https://jakarta.ee/specifications/xml-binding/. -
EclipseLink also includes Database Web Service (DBWS), which provides access to relational database artifacts by using a Jakarta XML Web Services 4.0 web service.
EclipseLink also provides support for Oracle Spatial and Oracle XDB mapping.
For more information about EclipseLink, including other supported services, see the EclipseLink project home at http://wiki.eclipse.org/EclipseLink and the EclipseLink Documentation Center at http://wiki.eclipse.org/EclipseLink/UserGuide.
In addition to all of EclipseLink, Oracle TopLink includes:
-
TopLink Grid, an integration between EclipseLink JPA with Oracle Coherence that allows EclipseLink to use Oracle Coherence as a level 2 (L2) cache and persistence layer for entities. See Developing Applications with Oracle Coherence.
Note:
You must have a license for Oracle Coherence to be able to use TopLink Grid.
-
Logging integration with WebLogic Server.
-
MBean support in WebLogic Server.
For information about developing, deploying, and configuring Oracle TopLink applications, see the following:
See also the following EclipseLink resources:
-
EclipseLink Documentation Center at
http://www.eclipse.org/eclipselink/documentation/ -
EclipseLink examples at
http://wiki.eclipse.org/EclipseLink/Examples.
Oracle Database Identity Column Compatibility with EclipseLink in WebLogic Server 26.1.0.0.0
In WebLogic Server 26.1.0.0.0, applications that use EclipseLink with Oracle Database should not rely on the EclipseLink discovery of Oracle system-managed identity sequences for entities mapped with GenerationType.IDENTITY. If an entity maps its primary key to an Oracle column defined as GENERATED ALWAYS AS IDENTITY, EclipseLink may attempt to insert an explicit primary-key value, causing Oracle Database to reject the insert with the ORA-32795 database error message.
To migrate these applications, use an application-owned sequence and configure the entity with @SequenceGenerator and GenerationType.SEQUENCE as demonstrated in Example 7-1. The sequence must be initialized above the current maximum primary-key value. The table definition must also allow application-provided primary-key values, such as by using GENERATED BY DEFAULT AS IDENTITY or another DBA-approved schema migration. Do not rely on Oracle’s system-managed identity sequence as the application sequence.
Example 7-1 Configuring an entity with @SequenceGenerator and GenerationType.SEQUENCE
@Id
@SequenceGenerator(
name = "usersSeq",
sequenceName = "USERS_ID_SEQ",
allocationSize = 1
)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "usersSeq"
)
private Long id;Specifying a Persistence Provider
You can specify what persistence provider to use for a persistence unit in the application code or by accepting the default persistence provider set for the WebLogic Server domain, as described in the following sections:
Setting the Default Provider for the Domain
Unless you specify otherwise, TopLink is used as the default persistence provider for a WebLogic Server domain. The default provider is used for any entities in an application that are not configured to use a different persistence provider. The default provider is used for both injected and application-managed entity managers and factories.
You can set the default provider in the WebLogic Remote Console or by directly setting JPAMBean.DefaultJPAProvider.
If you change the default provider, you must do the following for any deployed applications that do not specify a JPA provider:
-
Restart applications that use application-managed entity manager factories.
-
Redeploy applications that use injected entity manager factories or entity managers.
Parent topic: Specifying a Persistence Provider
Specifying the Persistence Provider in an Application
A persistence provider specified in an application takes precedence over the default provider set for the WebLogic Server domain.
You can set the provider to use in the following ways:
-
Specify the provider in the
<provider>element for a persistence unit in thepersistence.xmlfile, for example:<persistence-unit name="example"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> ... </persistence-unit> -
Specify the provider in the
jakarta.persistence.providerproperty passed to theMapparameter of thejakarta.persistence.Persistence.createEntityManagerFactory(String, Map)method.
Note:
WebLogic Server 26.1.0.0.0 uses Jakarta Persistence 3.2 as the default for Jakarta EE 11 applications. If you want your applications to continue using the Jakarta Persistence 3.0 schema, explicitly declare version="3.0" and reference persistence_3_0.xsd in xsi:schemaLocation, as demonstrated in Example 7-2.
Update the descriptor to version 3.2 only when the application intentionally adopts Jakarta Persistence 3.2 descriptor features.
Example 7-2 Configure applications to use the Jakarta Persistence 3.0 schema
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
...
</persistence>Parent topic: Specifying a Persistence Provider