Example usage for org.hibernate.cfg Settings isSecondLevelCacheEnabled

List of usage examples for org.hibernate.cfg Settings isSecondLevelCacheEnabled

Introduction

In this page you can find the example usage for org.hibernate.cfg Settings isSecondLevelCacheEnabled.

Prototype

public boolean isSecondLevelCacheEnabled() 

Source Link

Usage

From source file:de.iteratec.iteraplan.presentation.dialog.Configuration.ConfigurationController.java

License:Open Source License

/**
 * Clears the Hibernate second-level cache.
 * /*w  w  w  .ja  v  a2  s .  co m*/
 * @return the init page
 */
@RequestMapping
public String clearHibernateCache() {
    Settings settings = sessionFactory.getSettings();
    if (settings.isSecondLevelCacheEnabled()) {
        Cache cache = sessionFactory.getCache();
        cache.evictEntityRegions();
        cache.evictCollectionRegions();
    }

    if (settings.isQueryCacheEnabled()) {
        Cache cache = sessionFactory.getCache();
        cache.evictDefaultQueryRegion();
        cache.evictQueryRegions();
    }

    return initPage;
}