Elastic Path Commerce Development

OpenJPA Data Caching

OpenJPA Data Caching

OpenJPA supports caching transactional persistent entities (anything submitted or updated regularly as an online transaction such as orders, payments and customers). By default, all relatively static objects, including catalog entities, are cached unless the following annotation is specified in the source code of the persistent entity class:

@DataCache(enabled = false)

OpenJPA is configured to use Ehcache for its data and query caches, as specified by jpa-persistence.xml in ep-core.

The OpenJPA L2 cache timeout defaults to one second so that data changes are immediately visible in development, QA, and staging environments. For live environments, cache timeouts can be increased to optimize performance using an external configuration file. See Configuring Ehcache for details.

For more information on configuring OpenJPA's properties, see the OpenJPA User's Guide.

Override Persistence Unit Properties

Occasionally you may wish to override some of the properties defined in the core persistence unit, or add new properties. To do so, add the properties to the persistencePropertyOverrides map in the core extension's ep-core-plugin.xml file. Do not add or change properties in any of the jpa-persistence.xml files, as the order in which these files are resolved cannot be guaranteed.