Skip Headers

# Queries and the Cache

Previous

Next

When you execute a query, TopLink retrieves the information from either the database or the TopLink session cache. You can configure the way queries use the TopLink cache to optimize performance.

TopLink maintains a client-side cache to reduce the number of read operations required from the database. TopLink caches objects written to and read from the database to maintain object identity. The sequence in which a query checks the cache and database affects query performance. By default, primary key queries check the cache before accessing the database, and all queries check the cache before rebuilding an object from its row.

Note: You can override the default behavior in the caching policy configuration information in the TopLink descriptor. For more information, see "Explicit Query Refreshes" .

This section illustrates ways to manipulate the relationship between query and cache, including the following:

- Configuring the Cache

- Using In-Memory Queries

- Primary Key Queries and the Cache

- Disabling the Identity Map Cache Update During a Read Query

- Refreshing the Cache

- Caching Query Results in the Session Cache

- Caching Query Results in the Query Cache

- Caching and EJB Finders