+

Search Tips   |   Advanced Search

Configure WSJPA ObjectCache to improve performance

The WebSphere Java Persistence API (WSJPA) extension to OpenJPA provides a read-only object cache that can improve performance in certain use cases. This configuration is only supported when we use WSJPA at the JPA 2.0 specification level.

Implement a WSJPA ObjectCache object can improve the performance of an application that has a set of data used in a static, read-only method, like accessing basic persistent fields and persisting unidirectional relationships to a read-only type. WSJPA ObjectCache is a non-distributed cache of read-only entities that operates at the EntityManagerFactory object level. These cached instances are shared by all EntityManager objects in the JVM, but the instances are not managed by any. When the feature is enabled, the ObjectCache object is examined before the application accesses the OpenJPA DataCache object and database, and persistent objects are loaded from the database and stored in the OpenJPA object cache. In addition, the ObjectCache implementation can be used with OpenJPA DataCache and QueryCache features for even greater performance.

Be aware of the following conditions and limitations:

We can enable the object cache for a single JVM environment, specify the types included in this cache, set its maximum element size, and specify timeout values.

The preferred property name is wsjpa.ObjectCache, but openjpa.ObjectCache is also a valid configuration.


Tasks


What to do next

To enable automatic loading of the entire ObjectCache when the first EntityManager object is created, follow the steps in the Pre-loading the WSJPA ObjectCache automatically topic. In addition, we can read more about caching in the OpenJPA User Guide for information about all caching extensions.

  • Pre-loading the WSJPA ObjectCache automatically
  • Developing JPA 2.x applications for a Java SE environment
  • Developing JPA 2.x applications for a Java EE environment