Example usage for javax.persistence Cache evict

List of usage examples for javax.persistence Cache evict

Introduction

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

Prototype

public void evict(Class cls);

Source Link

Document

Remove the data for entities of the specified class (and its subclasses) from 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);
    } else {/*from w ww . j  a va2  s  .  com*/
        cache.evictAll();
    }
    return query.executeUpdate();
}