Enviorment-
Hibernate- query cache and 2nd level cache is enabled
cache used- Ehcache with updatetimestampcache set to be eternal.
Problem- For a entity E, i have 2 rows in the table. So on query(to fetch all rows) via criteria with setcacheable(true), first time the 2nd level cache and query cache are populated.
Any further execution of the same query via criteria with setcacheable(true) is served from query cache. So far so good.
Problem- After a new object of entity E is saved using hibernate (no now there are 3 rows in table for entity E) ,via a transactional service layer method. Any Further query to fetch rows for entity E (with setcacheable(true)) returns only 2 objects. Where in it should return 3 objects.
It seems the query cache for Entity E is not in validated when a new entity is saved in its table.