javahibernatesecond-level-cachequery-cache

Update Query Cache in hibernate for multiple records


Second level query cache is enabled and I am executing update query which is updating more than two records of that entity in DB.
1) Is that reflected in second level cache for that entities?
2) If they are getting cached then those entities are accessed through non-query(entity level) cache ?


Solution

  • Any query that you have with that entity type will be invalidated whenever there's an update or insert on that entity type. This means that the query and its results get removed from the query cache, and the next time the query is executed after the update it'd be cached again. You can find a few more details in this recent response I sent.