Fixed
Details
Assignee
Former userFormer user(Deactivated)Reporter
Former userFormer user(Deactivated)Components
Fix versions
Priority
Major
Details
Details
Assignee
Former user
Former user(Deactivated)Reporter
Former user
Former user(Deactivated)Components
Fix versions
Priority
Created January 16, 2015 at 10:22 PM
Updated January 16, 2015 at 11:37 PM
Resolved January 16, 2015 at 11:37 PM
Add an EntityManager test case that illustrates second-level cache eviction expectations when using QueryHints.HINT_CACHEABLE.
EntityManagerFactory().getCache().evictAll() only evicts entity regions of the second-level cache. The collection and query cache regions are left intact. As a result, query results can still be found in the query cache, but each entity referenced in that query result will result in a "miss" because the entity itself has been evicted from the entity region of the second-level cache. Hibernate will load each "missed" entity from the database (rather than re-executing the original query to obtain all entity data).
To avoid loading each "missed" entity, the query cache region should also be evicted using:
EntityManager.unwrap( HibernateEntityManagerImplementor.class )
.getFactory()
.getSessionFactory()
.getCache()
.evictQueryRegions();