We're updating the issue view to help you get more done. 

Add EntityManager test case illustrating usage of query cache

Description

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();

Environment

None

Status

Assignee

Gail Badner

Reporter

Gail Badner

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Priority

Major