Esempio n. 1
0
 public void clear2ndLevelHibernateCache() {
   Session s = (Session) em.getDelegate();
   SessionFactory sf = s.getSessionFactory();
   //        sf.evict(User.class);
   //        sf.getCache().evictEntity(User.class, BaseEntity.START_SEQ);
   //        sf.getCache().evictEntityRegion(User.class);
   sf.getCache().evictQueryRegions();
   sf.getCache().evictDefaultQueryRegion();
   sf.getCache().evictCollectionRegions();
   sf.getCache().evictEntityRegions();
 }
 public void evictAll() {
   sessionFactory.getCache().evictEntityRegions();
   // TODO : if we want to allow an optional clearing of all cache data, the additional calls
   // would be:
   //			sessionFactory.getCache().evictCollectionRegions();
   //			sessionFactory.getCache().evictQueryRegions();
 }
  @AggrEventsTransactional
  @Override
  public void evictAggregates(Map<Class<?>, Collection<Serializable>> entitiesToEvict) {
    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++;
        }
      }
    }

    logger.debug(
        "Evicted {} entities and {} collections from hibernate caches",
        evictedEntities,
        evictedCollections);
  }
Esempio n. 4
0
 public void clear2ndCache() {
   sessionFactory.getCache().evictEntityRegions();
   sessionFactory.getCache().evictCollectionRegions();
   sessionFactory.getCache().evictDefaultQueryRegion();
   sessionFactory.getCache().evictQueryRegions();
 }
 public void evict(Class entityClass) {
   sessionFactory.getCache().evictEntityRegion(entityClass);
 }
 public void evict(Class entityClass, Object identifier) {
   sessionFactory.getCache().evictEntity(entityClass, (Serializable) identifier);
 }
 public boolean contains(Class entityClass, Object identifier) {
   return sessionFactory.getCache().containsEntity(entityClass, (Serializable) identifier);
 }
Esempio n. 8
0
 public void setSessionFactory(SessionFactory sessionFactory) {
   System.out.println("sessionFactory" + sessionFactory.getCache());
   System.out.println("thisss" + sessionFactory.getCache());
   this.sessionFactory = sessionFactory;
 }