HHH-7150 added Cache#evictAllRegions

This commit is contained in:
Brett Meyer 2013-10-07 12:14:17 -04:00
parent 4a898c5524
commit 0ba9a3a289
4 changed files with 16 additions and 5 deletions

View File

@ -185,4 +185,9 @@ public interface Cache {
* Evict data from all query regions.
*/
public void evictQueryRegions();
/**
* Evict all data from the cache.
*/
public void evictAllRegions();
}

View File

@ -354,4 +354,13 @@ public class CacheImpl implements CacheImplementor {
public RegionFactory getRegionFactory() {
return regionFactory;
}
@Override
public void evictAllRegions() {
evictCollectionRegions();
evictDefaultQueryRegion();
evictEntityRegions();
evictQueryRegions();
evictNaturalIdRegions();
}
}

View File

@ -557,6 +557,7 @@ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory {
}
public void evictAll() {
// Evict only the "JPA cache", which is purely defined as the entity regions.
sessionFactory.getCache().evictEntityRegions();
// TODO : if we want to allow an optional clearing of all cache data, the additional calls would be:
// sessionFactory.getCache().evictCollectionRegions();

View File

@ -441,11 +441,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
protected void cleanupCache() {
if ( sessionFactory != null ) {
sessionFactory.getCache().evictCollectionRegions();
sessionFactory.getCache().evictDefaultQueryRegion();
sessionFactory.getCache().evictEntityRegions();
sessionFactory.getCache().evictQueryRegions();
sessionFactory.getCache().evictNaturalIdRegions();
sessionFactory.getCache().evictAllRegions();
}
}