本文整理汇总了Java中javax.persistence.Cache类的典型用法代码示例。如果您正苦于以下问题:Java Cache类的具体用法?Java Cache怎么用?Java Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cache类属于javax.persistence包,在下文中一共展示了Cache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: evictSecondLevelCache
import javax.persistence.Cache; //导入依赖的package包/类
/**
* 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());
}
}
}
开发者ID:mateli,项目名称:OpenCyclos,代码行数:22,代码来源:BaseDAOImpl.java
示例2: test
import javax.persistence.Cache; //导入依赖的package包/类
@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());
}
开发者ID:CeON,项目名称:saos,代码行数:27,代码来源:SecondLevelCacheTest.java
示例3: createQueryCacheAndEvictAllThenRetry
import javax.persistence.Cache; //导入依赖的package包/类
@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("#####################################################################");
}
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:20,代码来源:QueryCacheTest.java
示例4: getCache
import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
// TODO : cache the cache reference?
if ( ! isOpen() ) {
throw new IllegalStateException("EntityManagerFactory is closed");
}
return new JPACache( sessionFactory );
}
开发者ID:GovernIB,项目名称:helium,代码行数:8,代码来源:EntityManagerFactoryImpl.java
示例5: testRoomsAreCached
import javax.persistence.Cache; //导入依赖的package包/类
@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()));
}
开发者ID:koenighotze,项目名称:Hotel-Reservation-Tool,代码行数:10,代码来源:RoomCacheTest.java
示例6: testTransientRoomsAreNotCached
import javax.persistence.Cache; //导入依赖的package包/类
@Test
public void testTransientRoomsAreNotCached() {
Room room = new Room("", RoomEquipment.BUDGET);
Cache cache = getEntityManager().getEntityManagerFactory().getCache();
assertFalse("Rooms should be cached ", cache.contains(Room.class, room.getId()));
}
开发者ID:koenighotze,项目名称:Hotel-Reservation-Tool,代码行数:8,代码来源:RoomCacheTest.java
示例7: destroy
import javax.persistence.Cache; //导入依赖的package包/类
public static void destroy() {
if (emf == null) {
return;
}
Cache cache = emf.getCache();
log.debug("###### EVICT ALL ######");
cache.evictAll();
emf.close();
}
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:11,代码来源:EntityTestUtils.java
示例8: evict
import javax.persistence.Cache; //导入依赖的package包/类
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);
}
}
开发者ID:hohonuuli,项目名称:vars,代码行数:9,代码来源:JPACacheProvider.java
示例9: invoke
import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Object invoke(Object... args) {
Cache secondLevelCache = getEntityManagerFactory(args).getCache();
if (secondLevelCache != null) {
secondLevelCache.evictAll();
}
return null;
}
开发者ID:jipijapa,项目名称:jipijapa,代码行数:9,代码来源:HibernateStatistics.java
示例10: getCache
import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
return nativeEntityManagerFactory.getCache();
}
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:5,代码来源:CibetEntityManagerFactory.java
示例11: getCache
import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
return null;
}
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:5,代码来源:JdbcBridgeEntityManagerFactory.java
示例12: getCache
import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
return delegate.getCache();
}
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:4,代码来源:DelegatingEntityManagerFactory.java
示例13: getCache
import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
return null;
}
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:4,代码来源:MockitoPersistenceProvider.java
示例14: getCache
import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
throw new UnsupportedOperationException("Not supported.");
}
开发者ID:victorrentea,项目名称:training,代码行数:4,代码来源:MockStockPriceEntityManagerFactory.java
示例15: getCache
import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
return null;
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:5,代码来源:NoopEntityManagerFactory.java
示例16: getCache
import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
return CacheDummy.getInstance();
}
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:4,代码来源:JefEntityManagerFactory.java
示例17: getCache
import javax.persistence.Cache; //导入依赖的package包/类
@Override
public Cache getCache() {
return null;
}
开发者ID:apache,项目名称:olingo-odata2,代码行数:5,代码来源:JPQLBuilderFactoryTest.java
示例18: getCache
import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
return emf.getCache();
}
开发者ID:davidmoten,项目名称:functional-jpa,代码行数:4,代码来源:RichEntityManagerFactory.java
示例19: getCache
import javax.persistence.Cache; //导入依赖的package包/类
public Cache getCache() {
return entityManagerFactory.getCache();
}
开发者ID:spearal,项目名称:spearal-jpa2,代码行数:4,代码来源:EntityManagerFactoryWrapper.java
示例20: clearCache
import javax.persistence.Cache; //导入依赖的package包/类
public DAO<T> clearCache() {
Cache cache = entityManager.getEntityManagerFactory().getCache();
cache.evict(entityClass);
return this;
}
开发者ID:ivmarcos,项目名称:query,代码行数:6,代码来源:DAO.java
注:本文中的javax.persistence.Cache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论