Example usage for org.hibernate Cache evictDefaultQueryRegion

List of usage examples for org.hibernate Cache evictDefaultQueryRegion

Introduction

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

Prototype

void evictDefaultQueryRegion();

Source Link

Document

Evicts all cached query results from the default region.

Usage

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

License:Apache License

/**
 * ?jpa EntityManagerFactory  /*from ww  w . j ava 2 s.  c o 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.daphne.es.monitor.web.controller.HibernateCacheMonitorController.java

License:Apache License

@RequestMapping(value = "/evictQuery")
@ResponseBody//  w  ww . ja v a2s . c o  m
public String evictQuery(@RequestParam(value = "queries", required = false) String[] queries) {

    boolean queriesEmpty = ArrayUtils.isEmpty(queries);

    Cache cache = HibernateUtils.getCache(em);

    if (queriesEmpty) {
        cache.evictQueryRegions();
        cache.evictDefaultQueryRegion();
    } else {
        for (String query : queries) {
            cache.evictQueryRegion(query);
        }
    }

    return "??";
}

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

License:Apache License

/**
 * ?jpa EntityManagerFactory  //from  www.ja v  a 2s.  com
 * 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.
 * /*from   w  ww  .j ava2 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;
}

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();/*from  ww w  .  jav a2  s  .c o  m*/
            cache.evictCollectionRegions();
            cache.evictEntityRegions();
        }
    }
}