微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.persistence.Cache的实例源码

项目:OpenCyclos    文件BaseDAOImpl.java   
/**
 * evicts all second-level cache elements which Could get stale on entity updates
 */
protected void evictSecondLevelCache() {
    Cache cache = entityManager.getEntityManagerFactory().getCache();

    // If this DAO is cached,evict the collection regions,as we don't kNow which ones will point out to it
    if (hasCache) {
        synchronized (cache) {
            // We must invalidate all collection regions,as we don't kNow which other entities have many-to-many relationships with this one
            cache.evict(getEntityType());
        }
    }

    // evict the query cache region
    if (queryCacheRegion != null) {
        synchronized (cache) {
            cache.evict(getEntityType());
        }
    }
}
项目:saos    文件SecondLevelCacheTest.java   
@Test
public void test() {
    Cache cache = entityManager.getEntityManagerFactory().getCache();
    cache.evictAll();
    Statistics statistics = ((Session)(entityManager.getDelegate())).getSessionFactory().getStatistics();
    statistics.clear();

    CommonCourt commonCourt = testPersistenceObjectFactory.createCcCourt(CommonCourtType.APPEAL);

    commonCourtRepository.findOne(commonCourt.getId());
    commonCourtRepository.findOne(commonCourt.getId());

    Assert.assertTrue(cache.contains(CommonCourt.class,commonCourt.getId()));
    Assert.assertTrue(cache.contains(CommonCourtDivision.class,commonCourt.getDivisions().get(0).getId()));
    Assert.assertTrue(cache.contains(CommonCourtDivision.class,commonCourt.getDivisions().get(1).getId()));
    cache.evict(CommonCourt.class);
    cache.evict(CommonCourtDivision.class);
    Assert.assertFalse(cache.contains(CommonCourt.class,commonCourt.getId()));
    Assert.assertFalse(cache.contains(CommonCourtDivision.class,commonCourt.getDivisions().get(0).getId()));
    Assert.assertFalse(cache.contains(CommonCourtDivision.class,commonCourt.getDivisions().get(1).getId()));

    Assert.assertEquals(5,statistics.getSecondLevelCachePutCount()); // 1 commonCourt + 2 ccDivision + 2 ccDivisionType
    Assert.assertEquals(2,statistics.getSecondLevelCacheHitCount());
    Assert.assertEquals(0,statistics.getSecondLevelCacheMissCount());

}
项目:hibernate4-memcached    文件QueryCacheTest.java   
@Test
public void createqueryCacheAndevictAllThenRetry() throws Exception {
    List<Author> beforeResults = getAuthorsWithQuery("Author query","어느나라");

    log.warn("#####################################################################");

    HibernateEntityManagerFactory entityManagerFactory = (HibernateEntityManagerFactory) EntityTestUtils.getEntityManagerFactory();
    org.hibernate.Cache cache = entityManagerFactory.getSessionFactory().getCache();
    cache.evictEntityRegions();
    cache.evictQueryRegions();
    cache.evictDefaultQueryRegion();
    cache.evictCollectionRegions();

    log.warn("just eviected all.");
    List<Author> againResults = getAuthorsWithQuery("Author query again after evict all","어느나라");

    assertthat(againResults).isEqualTo(beforeResults);
    log.warn("#####################################################################");
}
项目:helium    文件EntityManagerFactoryImpl.java   
public Cache getCache() {
    // Todo : cache the cache reference?
    if ( ! isopen() ) {
        throw new IllegalStateException("EntityManagerFactory is closed");
    }
    return new JPACache( sessionFactory );
}
项目:OpenCyclos    文件BaseDAOImpl.java   
/**
 * evicts all second-level cache elements which Could get stale on entity updates
 */
protected void evictSecondLevelCache(E entity) {
    if (hasCache) {
        Cache cache = entityManager.getEntityManagerFactory().getCache();
        synchronized (cache) {
            // We must invalidate all collection regions,as we don't kNow which other entities have many-to-many relationships with this one
            cache.evict(getEntityType(),entity.getId());
        }
    }
}
项目:Hotel-Reservation-Tool    文件RoomCacheTest.java   
@Test
public void testRoomsAreCached() {
    Room room = getEntityManager().find(Room.class,WELL_KNowN_ROOM_ID);

    assertthat(room,is(not(nullValue())));

    Cache cache = getEntityManager().getEntityManagerFactory().getCache();
    assertTrue("Rooms should be cached ",cache.contains(Room.class,room.getId()));
}
项目:Hotel-Reservation-Tool    文件RoomCacheTest.java   
@Test
public void testTransientRoomsAreNotCached() {
    Room room = new Room("",RoomEquipment.BUDGET);

    Cache cache = getEntityManager().getEntityManagerFactory().getCache();
    assertFalse("Rooms should be cached ",room.getId()));
}
项目:hibernate4-memcached    文件EntityTestUtils.java   
public static void destroy() {
    if (emf == null) {
        return;
    }

    Cache cache = emf.getCache();
    log.debug("###### evict ALL ######");
    cache.evictAll();
    emf.close();
}
项目:vars    文件JPACacheProvider.java   
private void evict(Cache cache,VARSObject entity) {
    try {
        cache.evict(entity.getClass(),entity.getPrimaryKey());
    }
    catch (Exception e) {
        log.info("Failed to evict " + entity + " from cache",e);
    }
}
项目:jipijapa    文件HibernateStatistics.java   
@Override
public Object invoke(Object... args) {
    Cache secondLevelCache = getEntityManagerFactory(args).getCache();
    if (secondLevelCache != null) {
        secondLevelCache.evictAll();
    }
    return null;
}
项目:cibet    文件CibetEntityManagerFactory.java   
@Override
public Cache getCache() {
   return nativeEntityManagerFactory.getCache();
}
项目:cibet    文件JdbcBridgeEntityManagerFactory.java   
@Override
public Cache getCache() {
   return null;
}
项目:jpasecurity    文件DelegatingEntityManagerFactory.java   
public Cache getCache() {
    return delegate.getCache();
}
项目:jpasecurity    文件MockitoPersistenceProvider.java   
public Cache getCache() {
    return null;
}
项目:training    文件MockStockPriceEntityManagerFactory.java   
public Cache getCache() {
    throw new UnsupportedOperationException("Not supported.");
}
项目:switchyard    文件NoopEntityManagerFactory.java   
@Override
public Cache getCache() {
    return null;
}
项目:ef-orm    文件JefEntityManagerFactory.java   
public Cache getCache() {
    return CacheDummy.getInstance();
}
项目:olingo-odata2    文件JPQLBuilderFactoryTest.java   
@Override
public Cache getCache() {
  return null;
}
项目:functional-jpa    文件RichEntityManagerFactory.java   
public Cache getCache() {
    return emf.getCache();
}
项目:spearal-jpa2    文件EntityManagerFactoryWrapper.java   
public Cache getCache() {
    return entityManagerFactory.getCache();
}
项目:query    文件DAO.java   
public DAO<T> clearCache() {
    Cache cache = entityManager.getEntityManagerFactory().getCache();
    cache.evict(entityClass);
    return this;
}
项目:query    文件DAO.java   
public DAO<T> clearallCache() {
    Cache cache = entityManager.getEntityManagerFactory().getCache();
    cache.evictAll();
    return this;
}
项目:hexa.tools    文件EntityManagerFactoryImpl.java   
@Override
public Cache getCache()
{
    assert false;
    return null;
}
项目:fuse-bxms-integ    文件NoopEntityManagerFactory.java   
@Override
public Cache getCache() {
    return null;
}
项目:raidenjpa    文件RaidenEntityManagerFactory.java   
public Cache getCache() {
    throw new noplansToImplementException();
}
项目:bundles    文件DelegatedEntityManagerFactory.java   
@Override
public Cache getCache() {
    return emf.getCache();
}
项目:tomee    文件ReloadableEntityManagerFactory.java   
@Override
public Cache getCache() {
    return delegate().getCache();
}
项目:kuali_rice    文件NullEntityManagerFactory.java   
/**
 * @see javax.persistence.EntityManagerFactory#getCache()
 */
public Cache getCache() {
    throw new UnsupportedOperationException("JPA is not enabled,this should not be called.");
}
项目:osgi-hibernate    文件EntityManagerFactoryWrapper.java   
public Cache getCache() {
    return wrapped.getCache();
}
项目:cloud-odata-java    文件JPQLBuilderFactoryTest.java   
@Test
public void testOdataJpaAccessFactory() {

  ODataJPAFactoryImpl oDataJPAFactoryImpl = new ODataJPAFactoryImpl();
  ODataJPAAccessFactory jpaAccessFactory = oDataJPAFactoryImpl
      .getoDataJPAAccessFactory();
  ODataJPAContextImpl oDataJPAContextImpl = new ODataJPAContextImpl();

  EntityManagerFactory emf = new EntityManagerFactory() {

    @Override
    public boolean isopen() {
      // Todo Auto-generated method stub
      return false;
    }

    @Override
    public Map<String,Object> getProperties() {
      // Todo Auto-generated method stub
      return null;
    }

    @Override
    public PersistenceUnitUtil getPersistenceUnitUtil() {
      // Todo Auto-generated method stub
      return null;
    }

    @Override
    public metamodel getmetamodel() {
      // Todo Auto-generated method stub
      return null;
    }

    @Override
    public CriteriaBuilder getCriteriaBuilder() {
      // Todo Auto-generated method stub
      return null;
    }

    @Override
    public Cache getCache() {
      // Todo Auto-generated method stub
      return null;
    }

    @SuppressWarnings("rawtypes")
    @Override
    public EntityManager createEntityManager(final Map arg0) {
      // Todo Auto-generated method stub
      return null;
    }

    @Override
    public EntityManager createEntityManager() {
      // Todo Auto-generated method stub
      return null;
    }

    @Override
    public void close() {
      // Todo Auto-generated method stub

    }
  };
  oDataJPAContextImpl.setEntityManagerFactory(emf);
  oDataJPAContextImpl.setPersistenceUnitName("pUnit");

  assertNotNull(jpaAccessFactory.getoDataJPAMessageService(new Locale(
      "en")));
  assertNotNull(jpaAccessFactory.createODataJPAContext());
  assertNotNull(jpaAccessFactory
      .createJPAEdmProvider(oDataJPAContextImpl));
  assertNotNull(jpaAccessFactory
      .createODataProcessor(oDataJPAContextImpl));

}
项目:@R_293_3270@    文件TestPersistenceProviderResolver.java   
@Override
public Cache getCache()
{
    return null;  
}
项目:vars    文件JPACacheProvider.java   
/**
 * Clear the second level cache
 */
public void clear() {

    Cache cache = kbEmf.getCache();
    cache.evictAll();

    cache = annoEmf.getCache();
    cache.evictAll();

    cache = miscEmf.getCache();
    cache.evictAll();

}
项目:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application    文件SecurityServiceImpl.java   
/**
 * Setter method for property <tt>cache</tt>.
 * @param cache value to be assigned to property cache
 */
public void setCache(Cache cache) {
    this.cache = cache;
}
项目:hexa.tools    文件EntityManagerFactory.java   
Cache getCache();

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。