Example usage for javax.persistence Cache evictAll

List of usage examples for javax.persistence Cache evictAll

Introduction

In this page you can find the example usage for javax.persistence Cache evictAll.

Prototype

public void evictAll();

Source Link

Document

Clear the cache.

Usage

From source file:com.haulmont.cuba.core.sys.QueryImpl.java

@Override
public int executeUpdate() {
    JpaQuery<T> query = getQuery();
    // In some cache configurations (in particular, when shared cache is on, but for some entities cache is set to ISOLATED),
    // EclipseLink does not evict updated entities from cache automatically.
    Cache cache = query.getEntityManager().getEntityManagerFactory().getCache();
    Class referenceClass = query.getDatabaseQuery().getReferenceClass();
    if (referenceClass != null) {
        cache.evict(referenceClass);//from  w ww  .  java 2  s . c  om
    } else {
        cache.evictAll();
    }
    return query.executeUpdate();
}