Example usage for org.hibernate Cache evictCollectionRegion

List of usage examples for org.hibernate Cache evictCollectionRegion

Introduction

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

Prototype

@Deprecated
default void evictCollectionRegion(String role) 

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 = "/evictCollection")
@ResponseBody/*from  ww w .  ja va 2 s .c o  m*/
public String evictCollection(
        @RequestParam(value = "collectionRoleNames", required = false) String[] collectionRoleNames,
        @RequestParam(value = "collectionEntityIds", required = false) Serializable[] collectionEntityIds) {

    boolean collectionRoleNamesEmpty = ArrayUtils.isEmpty(collectionRoleNames);
    boolean collectionEntityIdsEmpty = ArrayUtils.isEmpty(collectionEntityIds);

    Cache cache = HibernateUtils.getCache(em);

    if (collectionRoleNamesEmpty && collectionEntityIdsEmpty) {
        cache.evictEntityRegions();
    } else if (collectionEntityIdsEmpty) {
        for (String collectionRoleName : collectionRoleNames) {
            cache.evictCollectionRegion(collectionRoleName);
        }
    } else {
        for (String collectionRoleName : collectionRoleNames) {
            for (Serializable collectionEntityId : collectionEntityIds) {
                cache.evictCollection(collectionRoleName, collectionEntityIds);
            }
        }
    }

    return "??";
}