Skip to content

Commit

Permalink
HHH-7150 added Cache#evictAllRegions
Browse files Browse the repository at this point in the history
  • Loading branch information
brmeyer committed Oct 7, 2013
1 parent 4a898c5 commit 0ba9a3a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/Cache.java
Expand Up @@ -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();
}
Expand Up @@ -354,4 +354,13 @@ public Map<String, Region> getAllSecondLevelCacheRegions() {
public RegionFactory getRegionFactory() {
return regionFactory;
}

@Override
public void evictAllRegions() {
evictCollectionRegions();
evictDefaultQueryRegion();
evictEntityRegions();
evictQueryRegions();
evictNaturalIdRegions();
}
}
Expand Up @@ -557,6 +557,7 @@ public void evict(Class entityClass) {
}

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();
Expand Down
Expand Up @@ -441,11 +441,7 @@ public final void afterTest() throws Exception {

protected void cleanupCache() {
if ( sessionFactory != null ) {
sessionFactory.getCache().evictCollectionRegions();
sessionFactory.getCache().evictDefaultQueryRegion();
sessionFactory.getCache().evictEntityRegions();
sessionFactory.getCache().evictQueryRegions();
sessionFactory.getCache().evictNaturalIdRegions();
sessionFactory.getCache().evictAllRegions();
}
}

Expand Down

0 comments on commit 0ba9a3a

Please sign in to comment.