The SQL query cache will store the results in memory of any SQL query that executes a SELECT statement on a database table. Invocation of the following entity operation stereotypes will result in the results of that query being stored in the cache:
- read
- nsread
- nkread
- readmulti
- nsreadmulti
- nkreadmulti
- nsmulti
- ns with handcrafted SQL containing a SELECT statement
There are two exceptions to this rule:
- SQL queries that have the FOR UPDATE flag set to true will not have their results cached. These queries will always result in direct database access. This is due to the fact that this data is being read for modification and the subsequent update operation will result in that cache entry being invalidated.
- The results of specialized readmulti operations, where the operation is not an instance of StandardReadMultiOperation class, will not be cached. This is due to the fact that a customized ReadMultiOperation can modify the result set for a SQL query being executed. Since these results are not yet present in the cache, the cache cannot be invalidated which results in invalid data in the cache (i.e. the data cached for the SQL query does not reflect the data for that SQL query on the database).