Configure the JPA default persistence provider
Two persistence providers are included in the product: JPA for WebSphere Application Server persistence provider and Apache OpenJPA persistence provider. The Java Persistence API (JPA) for WebSphere Application Server persistence provider is the default provider for the product. We can use one of these two providers, or a third-party persistence provider, as the default provider.
If we have a default persistence provider, default Java Transaction API (JTA) data source JNDI name, and default non-JTA data source JNDI name values that were set in the product before V7.0, through the JVM properties, any change to these values through the console override values that were set with the JVM properties.
These properties include, com.ibm.websphere.jpa.default.provider, com.ibm.websphere.jpa.default.jta.datasource, and com.ibm.websphere.jpa.default.nonjta.datasource. Support for these properties has been deprecated. Any values that were set through these properties are displayed as default values on this panel. These values that are set through the console panel overrides any values set through the JVM properties.
While built from the Apache OpenJPA persistence provider, the JPA for WebSphere Application Server persistence provider contains the following enhancements and differences:
- Static SQL support using the DB2 pureQuery feature
- Access intent support
- Enhanced tracing support
- Version ID generation
- WebSphere product-specific commands and scripts
- Translated message files
- Check in-memory caches for lazily loaded many-to-one or one-to-one relationships.
Setting the wsjpa.BrokerImpl property to true specifies that the JPA implementation will attempt to load lazy fields from memory at run time if the foreign key data for the lazy fields are available. Use the following property:
<property name="wsjpa.BrokerImpl" value="checkCacheForLazyFields=true"/>
This property can be useful in many scenarios. For example, assume we have a person entity, Person(A), that has a one-to-one relationship to another person, Person(B), and Person(B) is stored in the L2 data cache. If this property is set, when the JPA implementation finds Person(A), the foreign key that is loaded from Person(A) will be used to populate the relationship from Person(A) to Person(B).
- The following table shows how the default values for the JPA for WebSphere Application Server persistence provider configuration properties are different from the Apache OpenJPA provider:
Property Apache OpenJPA default value JPA for WAS persistence provider default value openjpa.Compatibility StrictIdentityValues=false StrictIdentityValues=true openjpa.RuntimeUnenhancedClasses unsupported warn openjpa.DynamicEnhancementAgent true false open.jdbc.DriverDataSource auto simple
The OpenJPA compatibility property does not remove proxy types that OpenJPA generates for certain data types, especially date types such as GregorianCalendar. This omission can cause problems with deserialization. If a deserialization problem occurs, an error message, similar to the following message, is issued:gotcha
Error Message is:org.codehaus.jackson.map.JsonMappingException: Can not construct instance of org.apache.openjpa.util.java$util$GregorianCalendar$proxy, problem: no suitable creator method found at [Source: org.apache.http.conn.EofSensorInputStream@d83fbd5; line: 1, column: 4094]
In addition to the above property overrides, the use of the default JPA for WebSphere Application Server persistence provider also implies the use of the following JPA for WebSphere Application Server classes which override the corresponding classes in Apache OpenJPA:
com.ibm.ws.persistence.jdbc.kernel.ConstraintUpdateManager; com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCBrokerFactory; com.ibm.ws.persistence.jdbc.sql.DB2Dictionary; com.ibm.ws.persistence.jdbc.sql.OracleDictionary; com.ibm.ws.persistence.jdbc.sql.SQLFactoryImpl; com.ibm.ws.persistence.jdbc.sql.SQLServerDictionary; com.ibm.ws.persistence.kernel.WsJpaBrokerImpl; com.ibm.ws.persistence.kernel.WsJpaFinalizingBrokerImpl;If no JPA provider is configured in the <provider> element of the persistence.xml file within an EJB module, the default JPA provider currently configured for this server is used. The product is packaged with the JPA for WebSphere Application Server persistence provider defined as the default provider. However, it is possible to override this default and specify a different default through the console.
We can set the default persistence provider in one of two ways.
- Select the default JPA provider from a list of providers included with the product.
- Open the console.
- Click Servers > Application Servers
- Select a server.
- Click Container Services > Default Java Persistence API Settings
- Select Select a default persistence provider included with WebSphere Application Server.
- Click the slider and select from the list.
- Click Apply and save the configuration.
- Specify an alternative default persistence provider through the console.
- Open the console.
- Click Servers > Application Servers
- Select a server.
- Click Container Services > Default Java Persistence API Settings
- Select Specify an alternative default persistence provider.
- Enter the fully qualified JPA implementation class name of a JPA persistence provider in the box.
- Click Apply and save the configuration.
Subtopics
- Default Java Persistence API settings
The Java Persistence API (JPA) specification requires a default provider to be defined. If we have applications that use JPA, IBM recommends you use this page to provide default values. To increase the portability of the applications, we can use this page to configure the default JPA settings for applications running on this server instead of defining the <provider> element in each persistence unit in the applications. The JPA settings defined here are used for the persistence unit of an application only when the application does not define the JPA settings for that persistence unit.
- Use third-party persistence providers
Java Persistence API (JPA) for WebSphere Application Server supports third-party persistence providers in their application server environment.
Related tasks
Default Java Persistence API settings Configure persistence provider support in the application server Use third-party persistence providers Configure the default JTA and non-JTA data source JNDI names