Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents
 Search
 PDFComments
Comments


flush-clear.cache

Use eclipselink.flush-clear.cache to specify the EclipseLink EntityManager cache behavior when a clear method follows the flush method.


Values

Table 5-36 describes this persistence property's values.

Table 5-36 Valid Values for flush-clear.cache

Value Description

Drop

EclipseLink drops the entire EntityManager cache.

Although this is the fastest mode and uses the least memory, the shared cache may potentially contain stale data after performing the commit.

DropInvalidate

EclipseLink drops the entire EntityManager cache. Classes that have at least one updated or deleted object become invalid in the shared cache after performing the commit.

This mode is slower than Drop, but as efficient (in terms of memory usage) and prevents stale data.

Merge

EclipseLink drops objects the EntityManager cache that have not been flushed.

Although this mode leaves the shared cache in a perfect state after performing the commit, it is the least memory-efficient. In a very large transaction you may run out of memory.



Usage

You can specify this property when creating an EntityManagerFactory (in the map passed to the createEntityManagerFactory method or in the persistence.xml file), or an EntityManager (in the map passed to the createEntityManager method).

Note that the latter overrides the former.


Examples

Example 5-25 shows how to use this persistence property extension in the persistence.xml file.

Example 5-25 Using flush-clear.cache in persistence.xml

<property name="eclipselink.flush-clear.cache" value="Drop"/>

Example 5-26 shows how to use this extension in a property map

Example 5-26 Using flush-clear.cache in a Property Map

import org.eclipse.persistence.config.PersistenceUnitProperties;propertiesMap.put(PersistenceUnitProperties.FLUSH_CLEAR_CACHE, FlushClearCache.Drop);


See Also

For more information, see: