We wish to turn on the L2 cache on a system which has numerous legacy SQL queries. This raises the problem of stale data in the cache or reading data from the db that has been changed in the cache but not yet flushed.
There are a number of options available, but I was curious to know about exactly how HQL interacts with the L2 cache. I have examined the source code, particularly SessionImpl and it seems that an HQL query performs the following steps:
1. Create query plan.
2. Flush cached query space to db.
3. Translate HQL->SQL and perform query through JDBC
This means that using HQL maintains the consistency of the L2 cache but does not actually read from it.
Please correct me if I am wrong. I have searched for and read many posts related to this but the information is conflicting and I'd like a definitive answer. Thanks!
|