Package javax.persistence

Examples of javax.persistence.Cache


    * @see org.jboss.arquillian.persistence.JpaCacheEvictionStrategy#evictCache(javax.persistence.EntityManagerFactory)
    */
   @Override
   public final void evictCache(EntityManager em)
   {
      final Cache cache = em.getEntityManagerFactory().getCache();
      if (cache != null)
      {
         cache.evictAll();
      }
   }
View Full Code Here


          }
          Class<?> associatedClazz = associated.getClass();
          Method idGetter = associatedClazz
              .getDeclaredMethod("getId");
          EntityManagerFactory emf = em.getEntityManagerFactory();
          Cache emfCache = emf.getCache();
          emfCache.evict(associated.getClass(),
              idGetter.invoke(associated));
        } catch (Exception e) {
          log.warn("Error", e);
        }
      }
View Full Code Here

        };

        OperationStepHandler evictAllHandler = new AbstractMetricsHandler() {
            @Override
            void handle(final ModelNode response, final String name, ManagementLookup stats, OperationContext context) {
                Cache secondLevelCache = stats.getEntityManagerFactory().getCache();
                if (secondLevelCache != null) {
                    secondLevelCache.evictAll();
                }
            }
        };
        jpaHibernateRegistration.registerOperationHandler(OPERATION_EVICTALL, evictAllHandler, evictAll);
View Full Code Here

          }
          Class<?> associatedClazz = associated.getClass();
          Method idGetter = associatedClazz
              .getDeclaredMethod("getId");
          EntityManagerFactory emf = em.getEntityManagerFactory();
          Cache emfCache = emf.getCache();
          emfCache.evict(associated.getClass(),
              idGetter.invoke(associated));
        } catch (Exception e) {
          log.warn("Error", e);
        }
      }
View Full Code Here

          }
          Class<?> associatedClazz = associated.getClass();
          Method idGetter = associatedClazz
              .getDeclaredMethod("getId");
          EntityManagerFactory emf = em.getEntityManagerFactory();
          Cache emfCache = emf.getCache();
          emfCache.evict(associated.getClass(),
              idGetter.invoke(associated));
        } catch (Exception e) {
          log.warn("Error", e);
        }
      }
View Full Code Here

  public ORMModelInstance update(Map<String, Object> data) {
    ORMPersistenceManager orm = AdaptrexServices.getPersistenceManager(this.extConfig.getFactoryName());
    EntityManager em = (EntityManager) orm.getSession();
    EntityTransaction tx = em.getTransaction();
    EntityManagerFactory emf = em.getEntityManagerFactory();
    Cache emfCache = emf.getCache();
   
    try {
      tx.begin();
      for (String key : data.keySet()) {
        if (key.equals("id")) {
View Full Code Here

          }
          Class<?> associatedClazz = associated.getClass();
          Method idGetter = associatedClazz
              .getDeclaredMethod("getId");
          EntityManagerFactory emf = em.getEntityManagerFactory();
          Cache emfCache = emf.getCache();
          emfCache.evict(associated.getClass(),
              idGetter.invoke(associated));
        } catch (Exception e) {
          log.warn("Error", e);
        }
      }
View Full Code Here

        }

        assertNotNull(cacheProvider.getCacheManager());

        // Initialize Cache
        Cache cache = null;
        try
        {
            cache = cacheProvider.createCache(cacheName);
        }
        catch (CacheException e)
        {
            fail(e.getMessage());
        }
        assertNotNull(cache);
        assertEquals(cache.getClass(), EhCacheWrapper.class);

        EhCacheWrapper ehCache = (EhCacheWrapper) cache;

        assertEquals(0, ehCache.size());
View Full Code Here

          Object associated = getter.invoke(entity);
          if (associated == null) {continue;}
          Class<?> associatedClazz = associated.getClass();
          Method idGetter = associatedClazz.getDeclaredMethod("getId");
          EntityManagerFactory emf = em.getEntityManagerFactory();
          Cache emfCache = emf.getCache();
          emfCache.evict(associated.getClass(), idGetter.invoke(associated));
        } catch (Exception e) {
          log.warn("Error", e);
        }
      }
     
View Full Code Here

TOP

Related Classes of javax.persistence.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.