Example usage for org.hibernate Cache evictCollectionRegions

List of usage examples for org.hibernate Cache evictCollectionRegions

Introduction

In this page you can find the example usage for org.hibernate Cache evictCollectionRegions.

Prototype

@Deprecated
default void evictCollectionRegions() 

Source Link

Document

Evict data from all collection regions.

Usage

From source file:cn.guoyukun.spring.jpa.repository.hibernate.HibernateUtils.java

License:Apache License

/**
 * ?jpa EntityManagerFactory  //w ww  .j av a 2  s. co m
 * 1?
 * 2??
 * 3?
 * ?
 * jpa Cache api ?evict ?
 *
 * @param emf
 * @see org.hibernate.ejb.EntityManagerFactoryImpl.JPACache#evictAll()
 */
public static void evictLevel2Cache(EntityManagerFactory emf) {
    Cache cache = HibernateUtils.getCache(emf);
    cache.evictEntityRegions();
    cache.evictCollectionRegions();
    cache.evictDefaultQueryRegion();
    cache.evictQueryRegions();
    cache.evictNaturalIdRegions();
}

From source file:com.topsem.common.repository.jpa.hibernate.Hibernates.java

License:Apache License

/**
 * ?jpa EntityManagerFactory  //from  www .  j  a va2s  .c o  m
 * 1?
 * 2??
 * 3?
 * ?
 * jpa Cache api ?evict ?
 *
 * @param emf
 * @see org.hibernate.jpa.internal.EntityManagerFactoryImpl.JPACache#evictAll()
 */
public static void evictLevel2Cache(EntityManagerFactory emf) {
    Cache cache = Hibernates.getCache(emf);
    cache.evictEntityRegions();
    cache.evictCollectionRegions();
    cache.evictDefaultQueryRegion();
    cache.evictQueryRegions();
    cache.evictNaturalIdRegions();
}

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

License:Open Source License

/**
 * Clears the Hibernate second-level cache.
 * //www. ja  v a2  s  .  c  om
 * @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;
}

From source file:nl.strohalm.cyclos.dao.BaseDAOImpl.java

License:Open Source License

/**
 * Evicts all second-level cache elements which could get stale on entity updates
 *//*from  w  w  w. j  a v  a 2  s . co m*/
protected void evictSecondLevelCache() {
    final SessionFactory sessionFactory = getSessionFactory();

    // If this DAO is cached, evict the collection regions, as we don't know which ones will point out to it
    if (hasCache) {
        synchronized (sessionFactory) {
            final Cache cache = sessionFactory.getCache();
            // We must invalidate all collection regions, as we don't know which other entities have many-to-many relationships with this one
            cache.evictCollectionRegions();
        }
    }

    // Evict the query cache region
    if (queryCacheRegion != null) {
        synchronized (sessionFactory) {
            final Cache cache = sessionFactory.getCache();
            cache.evictQueryRegion(queryCacheRegion);
        }
    }
}

From source file:org.jboss.dashboard.database.hibernate.HibernateInitializer.java

License:Apache License

/**
 * Evict all cache information.//ww w  . j a v  a  2s .  com
 */
public synchronized void evictAllCaches() {
    Cache cache = getSessionFactory().getCache();
    cache.evictQueryRegions();
    cache.evictEntityRegions();
    cache.evictCollectionRegions();
}

From source file:org.ow2.bonita.util.DbTool.java

License:Open Source License

public static void cleanCache(final String domain, final String sessionFactoryName) throws Exception {
    // clean 2nd level cache:
    final SessionFactoryImplementor sessionFactory = getSessionFactory(domain, sessionFactoryName);
    if (sessionFactory != null) {
        Cache cache = sessionFactory.getCache();
        if (cache != null) {
            cache.evictDefaultQueryRegion();
            cache.evictQueryRegions();/*w w  w . j ava  2s . co m*/
            cache.evictCollectionRegions();
            cache.evictEntityRegions();
        }
    }
}