本文整理汇总了Java中org.hibernate.cache.spi.access.AccessType类的典型用法代码示例。如果您正苦于以下问题:Java AccessType类的具体用法?Java AccessType怎么用?Java AccessType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccessType类属于org.hibernate.cache.spi.access包,在下文中一共展示了AccessType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Override
public NaturalIdRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
if (AccessType.READ_ONLY.equals(accessType)) {
return new NaturalIdRegionAccessStrategyAdapter(
new ReadOnlyAccessDelegate<HazelcastNaturalIdRegion>(this, props));
}
if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
return new NaturalIdRegionAccessStrategyAdapter(
new NonStrictReadWriteAccessDelegate<HazelcastNaturalIdRegion>(this, props));
}
if (AccessType.READ_WRITE.equals(accessType)) {
return new NaturalIdRegionAccessStrategyAdapter(
new ReadWriteAccessDelegate<HazelcastNaturalIdRegion>(this, props));
}
throw new CacheException("AccessType \"" + accessType + "\" is not currently supported by Hazelcast.");
}
示例2: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Override
public EntityRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
if (AccessType.READ_ONLY.equals(accessType)) {
return new EntityRegionAccessStrategyAdapter(
new ReadOnlyAccessDelegate<HazelcastEntityRegion>(this, props));
}
if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
return new EntityRegionAccessStrategyAdapter(
new NonStrictReadWriteAccessDelegate<HazelcastEntityRegion>(this, props));
}
if (AccessType.READ_WRITE.equals(accessType)) {
return new EntityRegionAccessStrategyAdapter(
new ReadWriteAccessDelegate<HazelcastEntityRegion>(this, props));
}
throw new CacheException("AccessType \"" + accessType + "\" is not currently supported by Hazelcast.");
}
示例3: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Override
public CollectionRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
if (AccessType.READ_ONLY.equals(accessType)) {
return new CollectionRegionAccessStrategyAdapter(
new ReadOnlyAccessDelegate<HazelcastCollectionRegion>(this, props));
}
if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
return new CollectionRegionAccessStrategyAdapter(
new NonStrictReadWriteAccessDelegate<HazelcastCollectionRegion>(this, props));
}
if (AccessType.READ_WRITE.equals(accessType)) {
return new CollectionRegionAccessStrategyAdapter(
new ReadWriteAccessDelegate<HazelcastCollectionRegion>(this, props));
}
throw new CacheException("AccessType \"" + accessType + "\" is not currently supported by Hazelcast.");
}
示例4: testNaturalIdCacheEvictsEntityOnUpdate
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Test
public void testNaturalIdCacheEvictsEntityOnUpdate() {
Assume.assumeTrue(defaultAccessType == AccessType.READ_WRITE);
insertAnnotatedEntities(1);
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
//1 cache hit since dummy:0 just inserted and still in the cache
AnnotatedEntity toBeUpdated = session.byNaturalId(AnnotatedEntity.class).using("title", "dummy:0").getReference();
toBeUpdated.setTitle("dummy101");
tx.commit();
session.close();
assertEquals(1, sf.getStatistics().getNaturalIdCacheHitCount());
//dummy:0 should be evicted and this leads to a cache miss
session = sf.openSession();
Criteria criteria = session.createCriteria(AnnotatedEntity.class).add(Restrictions.naturalId().set("title","dummy:0"))
.setCacheable(true);
criteria.uniqueResult();
assertEquals(1, sf.getStatistics().getNaturalIdCacheMissCount());
}
示例5: testNaturalIdCacheStillHitsAfterIrrelevantNaturalIdUpdate
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Test
public void testNaturalIdCacheStillHitsAfterIrrelevantNaturalIdUpdate() {
Assume.assumeTrue(defaultAccessType == AccessType.READ_WRITE);
insertAnnotatedEntities(2);
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
//1 cache hit since dummy:1 just inserted and still in the cache
AnnotatedEntity toBeUpdated = session.byNaturalId(AnnotatedEntity.class).using("title", "dummy:1").getReference();
toBeUpdated.setTitle("dummy101");
tx.commit();
session.close();
assertEquals(1, sf.getStatistics().getNaturalIdCacheHitCount());
//only dummy:1 should be evicted from cache on contrary to behavior of hibernate query cache without natural ids
session = sf.openSession();
Criteria criteria = session.createCriteria(AnnotatedEntity.class).add(Restrictions.naturalId().set("title","dummy:0"))
.setCacheable(true);
criteria.uniqueResult();
//cache hit dummy:0 + previous hit
assertEquals(2, sf.getStatistics().getNaturalIdCacheHitCount());
}
示例6: testNaturalIdCacheEvictsEntityOnUpdate
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Test
public void testNaturalIdCacheEvictsEntityOnUpdate() {
Assume.assumeTrue(defaultAccessType == AccessType.READ_WRITE);
insertAnnotatedEntities(1);
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
//1 cache hit since dummy:0 just inserted and still in the cache
AnnotatedEntity toBeUpdated = (AnnotatedEntity)session.byNaturalId(AnnotatedEntity.class).using("title", "dummy:0").getReference();
toBeUpdated.setTitle("dummy101");
tx.commit();
session.close();
assertEquals(1, sf.getStatistics().getNaturalIdCacheHitCount());
//dummy:0 should be evicted and this leads to a cache miss
session = sf.openSession();
Criteria criteria = session.createCriteria(AnnotatedEntity.class).add(Restrictions.naturalId().set("title","dummy:0"))
.setCacheable(true);
criteria.uniqueResult();
assertEquals(1, sf.getStatistics().getNaturalIdCacheMissCount());
}
示例7: testNaturalIdCacheStillHitsAfterIrrelevantNaturalIdUpdate
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Test
public void testNaturalIdCacheStillHitsAfterIrrelevantNaturalIdUpdate() {
Assume.assumeTrue(defaultAccessType == AccessType.READ_WRITE);
insertAnnotatedEntities(2);
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
//1 cache hit since dummy:1 just inserted and still in the cache
AnnotatedEntity toBeUpdated = (AnnotatedEntity)session.byNaturalId(AnnotatedEntity.class).using("title", "dummy:1").getReference();
toBeUpdated.setTitle("dummy101");
tx.commit();
session.close();
assertEquals(1, sf.getStatistics().getNaturalIdCacheHitCount());
//only dummy:1 should be evicted from cache on contrary to behavior of hibernate query cache without natural ids
session = sf.openSession();
Criteria criteria = session.createCriteria(AnnotatedEntity.class).add(Restrictions.naturalId().set("title","dummy:0"))
.setCacheable(true);
criteria.uniqueResult();
//cache hit dummy:0 + previous hit
assertEquals(2, sf.getStatistics().getNaturalIdCacheHitCount());
}
示例8: createAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
/**
* @param accessType Hibernate L2 cache access type.
* @return Access strategy for given access type.
*/
HibernateAccessStrategyAdapter createAccessStrategy(AccessType accessType) {
switch (accessType) {
case READ_ONLY:
return factory.accessStrategyFactory().createReadOnlyStrategy(cache);
case NONSTRICT_READ_WRITE:
return factory.accessStrategyFactory().createNonStrictReadWriteStrategy(cache);
case READ_WRITE:
return factory.accessStrategyFactory().createReadWriteStrategy(cache);
case TRANSACTIONAL:
return factory.accessStrategyFactory().createTransactionalStrategy(cache);
default:
throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType);
}
}
示例9: hibernateConfiguration
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
/**
* @param accessType Hibernate L2 cache access type.
* @param igniteInstanceName Ignite instance name.
* @return Hibernate configuration.
*/
private Configuration hibernateConfiguration(AccessType accessType,
String igniteInstanceName) {
Configuration cfg = new Configuration();
cfg.addAnnotatedClass(Entity.class);
cfg.addAnnotatedClass(Entity2.class);
cfg.addAnnotatedClass(VersionedEntity.class);
cfg.addAnnotatedClass(ChildEntity.class);
cfg.addAnnotatedClass(ParentEntity.class);
cfg.setCacheConcurrencyStrategy(ENTITY_NAME, accessType.getExternalName());
cfg.setCacheConcurrencyStrategy(ENTITY2_NAME, accessType.getExternalName());
cfg.setCacheConcurrencyStrategy(VERSIONED_ENTITY_NAME, accessType.getExternalName());
cfg.setCacheConcurrencyStrategy(PARENT_ENTITY_NAME, accessType.getExternalName());
cfg.setCollectionCacheConcurrencyStrategy(CHILD_COLLECTION_REGION, accessType.getExternalName());
for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
cfg.setProperty(e.getKey(), e.getValue());
// Use the same cache for Entity and Entity2.
cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);
return cfg;
}
示例10: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
switch (accessType) {
case READ_ONLY:
if (metadata.isMutable()) {
log.warn("read-only cache configured for mutable entity [" + getName() + "]");
}
return new ReadOnlyMemcachedEntityRegionAccessStrategy(this, settings);
case READ_WRITE:
return new ReadWriteMemcachedEntityRegionAccessStrategy(this, settings);
case NONSTRICT_READ_WRITE:
return new NonStrictReadWriteMemcachedEntityRegionAccessStrategy(this, settings);
case TRANSACTIONAL:
return new TransactionalMemcachedEntityRegionAccessStrategy(this, cache, settings);
default:
throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
}
}
示例11: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
switch (accessType) {
case READ_ONLY:
if (metadata.isMutable()) {
log.warn("read-only cache configured for mutable entity ["
+ getName() + "]");
}
return new ReadOnlyMemcachedNaturalIdRegionAccessStrategy(this, settings);
case READ_WRITE:
return new ReadWriteMemcachedNaturalIdRegionAccessStrategy(this, settings, metadata);
case NONSTRICT_READ_WRITE:
return new NonStrictReadWriteMemcachedNaturalIdRegionAccessStrategy(this, settings);
case TRANSACTIONAL:
return new TransactionalMemcachedNaturalIdRegionAccessStrategy(this, settings);
default:
throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
}
}
示例12: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
switch (accessType) {
case READ_ONLY:
if (metadata.isMutable()) {
log.warn("read-only cache configured for mutable entity [" + getName() + "]");
}
return new ReadOnlyMemcachedCollectionRegionAccessStrategy(this, settings);
case READ_WRITE:
return new ReadWriteMemcachedCollectionRegionAccessStrategy(this, settings);
case NONSTRICT_READ_WRITE:
return new NonStrictReadWriteMemcachedCollectionRegionAccessStrategy(this, settings);
case TRANSACTIONAL:
return new TransactionalMemcachedCollectionRegionAccessStrategy(this, settings);
default:
throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
}
}
示例13: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Override
public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
switch ( accessType ) {
case READ_ONLY:
if ( getCacheDataDescription().isMutable() ) {
LOG.warnf( "read-only cache configured for mutable collection [ %s ]", getName() );
}
return new ReadOnlyNaturalIdRegionAccessStrategy( this );
case READ_WRITE:
return new ReadWriteNaturalIdRegionAccessStrategy( this );
case NONSTRICT_READ_WRITE:
return new NonstrictReadWriteNaturalIdRegionAccessStrategy( this );
case TRANSACTIONAL:
return new TransactionalNaturalIdRegionAccessStrategy( this );
// throw new UnsupportedOperationException( "doesn't support this access strategy" );
default:
throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
}
}
示例14: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Override
public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
switch ( accessType ) {
case READ_ONLY:
if ( getCacheDataDescription().isMutable() ) {
LOG.warnf( "read-only cache configured for mutable collection [ %s ]", getName() );
}
return new ReadOnlyCollectionRegionAccessStrategy( this );
case READ_WRITE:
return new ReadWriteCollectionRegionAccessStrategy( this );
case NONSTRICT_READ_WRITE:
return new NonstrictReadWriteCollectionRegionAccessStrategy( this );
case TRANSACTIONAL:
return new TransactionalCollectionRegionAccessStrategy( this );
// throw new UnsupportedOperationException( "doesn't support this access strategy" );
default:
throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
}
}
示例15: buildAccessStrategy
import org.hibernate.cache.spi.access.AccessType; //导入依赖的package包/类
@Override
public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
switch ( accessType ) {
case READ_ONLY:
if ( getCacheDataDescription().isMutable() ) {
LOG.warnf( "read-only cache configured for mutable entity [ %s ]", getName() );
}
return new ReadOnlyEntityRegionAccessStrategy( this );
case READ_WRITE:
return new ReadWriteEntityRegionAccessStrategy( this );
case NONSTRICT_READ_WRITE:
return new NonstrictReadWriteEntityRegionAccessStrategy( this );
case TRANSACTIONAL:
// throw new UnsupportedOperationException( "doesn't support this access strategy" );
return new TransactionalEntityRegionAccessStrategy( this );
default:
throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
}
}