项目: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
项目: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
项目:vars
文件:JPACacheProvider.java
项目: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;
}
public Cache getCache() {
return delegate.getCache();
}
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();
}
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
项目:hexa.tools
文件:EntityManagerFactoryImpl.java
@Override
public Cache getCache()
{
assert false;
return null;
}
@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.");
}
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));
}
@Override
public Cache getCache()
{
return null;
}
项目:vars
文件:JPACacheProvider.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] 举报,一经查实,本站将立刻删除。