Package org.hibernate

Examples of org.hibernate.Cache


     *
     * @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();
    }
View Full Code Here


            @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 "操作成功";
View Full Code Here


        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 "操作成功";
View Full Code Here

            @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 "操作成功";
    }
View Full Code Here

        int evictedEntities = 0;
        int evictedCollections = 0;
       
        final Session session = getEntityManager().unwrap(Session.class);
        final SessionFactory sessionFactory = session.getSessionFactory();
        final Cache cache = sessionFactory.getCache();
       
       
        for (final Entry<Class<?>, Collection<Serializable>> evictedEntityEntry : entitiesToEvict.entrySet()) {
            final Class<?> entityClass = evictedEntityEntry.getKey();
            final List<String> collectionRoles = getCollectionRoles(sessionFactory, entityClass);
           
            for (final Serializable id : evictedEntityEntry.getValue()) {
                cache.evictEntity(entityClass, id);
                evictedEntities++;
               
                for (final String collectionRole : collectionRoles) {
                    cache.evictCollection(collectionRole, id);
                    evictedCollections++;
                }
            }
        }
       
View Full Code Here

        final String serverName = this.portalInfoProvider.getUniqueServerName();
        final String previousServerName = eventAggregatorStatus.getServerName();
        if (previousServerName != null && !serverName.equals(previousServerName)) {
            this.logger.debug("Last aggregation run on {} clearing all aggregation caches", previousServerName);
            final Session session = getEntityManager().unwrap(Session.class);
            final Cache cache = session.getSessionFactory().getCache();
            cache.evictEntityRegions();
        }
       
        eventAggregatorStatus.setServerName(serverName);
       
        //Calculate date range for aggregation
View Full Code Here

TOP

Related Classes of org.hibernate.Cache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.