Skip Headers

# Caching Options

Previous

Next

You can apply various configurations to the underlying query to achieve the correct caching behavior for the application. There are several ways to control the caching options for queries. For most queries, you can set caching options using TopLink Workbench.

You can set the caching options on a per-finder basis. Table: Finder Caching Options lists the valid values.

Finder Caching Options

This Setting . . . | Causes Finders to . . . | When the Search Involves a Finder That . . .
--- | --- | ---
`ConformResultsInUnitOfWork` Foot 1 | Check the unit of work cache before querying the session cache or the database. The finder's results always conform to uncommitted new, deleted, and changed objects. | Returns either a single bean or a collection.
`DoNotCheckCache` | Query the database, bypassing the TopLink internal caches. | Returns either a single bean or a collection.
`CheckCacheByExactPrimaryKey` | Check the session cache for the object. | Contains only a primary key, and returns a single bean.
`CheckCacheByPrimaryKey` | Check the session cache for the object. | Contains a primary key (and may contain other search parameters), and returns a single bean.
`CheckCacheThenDatabase` | Search the session cache before accessing the databas.e | Returns a single bean.
`CheckCacheOnly` | Search the parent session cache only (not the unit of work cache), but not the database. | Returns either a single bean or a collection.

Footnote 1 Default.

For more information about the TopLink queries, as well as the TopLink unit of work and how it integrates with JTS, see Understanding TopLink Transactions.

Note: To apply caching options to finders with manually created queries (`findOneByQuery`, `findManyByQuery`), use the TopLink API.