I am trying to use Hibernate query cache in my application.
Hibernate version: 4.3.11
EHCache version: 2.10.5
I am able to get the query cache working and it is caching the results so the subsequent executions of the same read query (with same parameters) is fetching data from the cache.
Now I try to insert a record, using hibernate API, that matches with the query predicates.
Once the record is inserted, I execute the read query again and it goes to fetch data from database and then subsequent executions again use cache.
From this what I understand is: when the record (that matches the query predicates and parameters) is inserted into the database, the query cache with old data is invalidated so the next query execution goes to database. The question I have here is: when the insert of record that matches the query predicates and parameters is done, can the hibernate also update the query cache with the new results so the query cache now has latest results and the next read query execution doesn’t need to go back to database ?