Explicit invalidation in the Persistence Manager Cache

Note: This page applies to WAS Version 5.0.2 and later only.

Container managed persistence (CMP) entity beans can be configured as long-lifetime beans. A long-lifetime bean is one that is configured with Lifetime In Cache Usage equal to a value other than the default OFF. For more information, see Entity bean assembly settings Go to Help documentation. A value other than OFF means that data for this bean is cached beyond the end of the transaction in which the bean was obtained by a finder or other method. The Lifetime In Cache Usage and Lifetime In Cache values control the basic length of time the cached data remains valid. When the specified time runs out, the cached data is no longer valid.

However, there is also an API that lets the client application code explicitly invalidate the cached data of a bean on demand, superceding the basic lifetime of the cache data as controlled by the Lifetime In Cache Usage and Lifetime In Cache settings. This is useful where an application that does not use CMP beans modifies the data that underlies a CMP bean (for example, it updates a database table to which a CMP bean is mapped). Such an application can inform WAS that any cached version of this bean data is stale and no longer matches what is in the database. The data should be invalidated (in essence, discarded). For CMP beans that cannot tolerate stale data, this is an important feature.

Because the PM Cache Invalidation mechanism does consume resources in exchange for its benefits, it is not enabled by default. To enable it, see Set Persistence Manager Cache Invalidation Go to Help documentation.

For more information, see Example: explicit invalidation in the Persistence Manager Cache.