当前位置: 首页>>代码示例>>Java>>正文


Java AccessType类代码示例

本文整理汇总了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.");
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:17,代码来源:HazelcastNaturalIdRegion.java

示例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.");
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:17,代码来源:HazelcastEntityRegion.java

示例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.");
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:17,代码来源:HazelcastCollectionRegion.java

示例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());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:26,代码来源:NaturalIdTest.java

示例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());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:27,代码来源:NaturalIdTest.java

示例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());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:26,代码来源:NaturalIdTest.java

示例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());
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:27,代码来源:NaturalIdTest.java

示例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);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:HibernateTransactionalDataRegion.java

示例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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:30,代码来源:HibernateL2CacheSelfTest.java

示例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 + "]");
        }
    }
 
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:19,代码来源:MemcachedEntityRegion.java

示例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 + "]");
        }
    }
 
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:21,代码来源:MemcachedNaturalIdRegion.java

示例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 + "]");
        }
    }
 
开发者ID:mihaicostin,项目名称:hibernate-l2-memcached,代码行数:19,代码来源:MemcachedCollectionRegion.java

示例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 + "]" );
		}
	}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:20,代码来源:NaturalIdRegionImpl.java

示例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 + "]" );
		}
	}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:20,代码来源:CollectionRegionImpl.java

示例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 + "]" );
		}

	}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:22,代码来源:EntityRegionImpl.java


注:本文中的org.hibernate.cache.spi.access.AccessType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。