Java Reference
In-Depth Information
To specify that an entity must not be cached, add a @Cacheable annotation and set it to
false :
@Cacheable(false)
@Entity
public class OrderStatus { ... }
When the ENABLE_SELECTIVE cache mode is set, the persistence provider will cache
any entities that have the @Cacheable(true) annotation and any subclasses of that
entity that have not been overridden. The persistence provider will not cache entities
that have @Cacheable(false) or have no @Cacheable annotation. That is, the
ENABLE_SELECTIVE mode will cache only entities that have been explicitly marked
for the cache using the @Cacheable annotation.
When the DISABLE_SELECTIVE cache mode is set, the persistence provider will cache
any entities that do not have the @Cacheable(false) annotation. Entities that do not
have @Cacheable annotations, and entities with the @Cacheable(true) annotation
will be cached. That is, the DISABLE_SELECTIVE mode will cache all entities that have
not been explicitly prevented from being cached.
If the cache mode is set to UNDEFINED , or is left unset, the behavior of entities annotated
with @Cacheable is undefined. If the cache mode is set to ALL or NONE , the value of
the @Cacheable annotation is ignored by the persistence provider.
Specifying the Cache Mode Settings to Improve Performance
To adjust the cache mode settings for a persistence unit, specify one of the cache modes as
the value of the shared-cache-mode element in the persistence.xml deploy-
ment descriptor (shown in bold ):
Click here to view code image
<persistence-unit name="examplePU" transaction-type="JTA">
<provider-
>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/__default</jta-data-source>
<shared-cache-mode>DISABLE_SELECTIVE</shared-cache-mode>
</persistence-unit>
Search WWH ::




Custom Search