Example usage for org.hibernate Cache evictEntityRegion

List of usage examples for org.hibernate Cache evictEntityRegion

Introduction

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

Prototype

@Deprecated
default void evictEntityRegion(String entityName) 

Source Link

Document

Evicts all entity data from the given region (i.e.

Usage

From source file:com.daphne.es.monitor.web.controller.HibernateCacheMonitorController.java

License:Apache License

@RequestMapping(value = "/evictEntity")
@ResponseBody/*from   w  w w  .  j a v a2 s. co m*/
public String evictEntity(@RequestParam(value = "entityNames", required = false) String[] entityNames,
        @RequestParam(value = "entityIds", required = false) Serializable[] entityIds) {

    boolean entityNamesEmpty = ArrayUtils.isEmpty(entityNames);
    boolean entityIdsEmpty = ArrayUtils.isEmpty(entityIds);

    Cache cache = HibernateUtils.getCache(em);

    if (entityNamesEmpty && entityIdsEmpty) {
        cache.evictEntityRegions();
    } else if (entityIdsEmpty) {
        for (String entityName : entityNames) {
            cache.evictEntityRegion(entityName);
        }
    } else {
        for (String entityName : entityNames) {
            for (Serializable entityId : entityIds) {
                cache.evictEntity(entityName, entityId);
            }
        }
    }

    return "??";
}