Example usage for org.hibernate.cache.spi.access AccessType TRANSACTIONAL

List of usage examples for org.hibernate.cache.spi.access AccessType TRANSACTIONAL

Introduction

In this page you can find the example usage for org.hibernate.cache.spi.access AccessType TRANSACTIONAL.

Prototype

AccessType TRANSACTIONAL

To view the source code for org.hibernate.cache.spi.access AccessType TRANSACTIONAL.

Click Source Link

Document

A read and write strategy where isolation/locking is maintained in conjunction with a JTA transaction.

Usage

From source file:com.googlecode.hibernate.memcached.region.MemcachedCollectionRegion.java

License:Apache License

public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
    if (AccessType.READ_ONLY.equals(accessType)) {
        if (metadata.isMutable()) {
            log.warn("read-only cache configured for mutable entity [" + getName() + "]");
        }//from ww  w. ja va  2 s  .c o m
        return new ReadOnlyMemcachedCollectionRegionAccessStrategy(this, settings);
    } else if (AccessType.READ_WRITE.equals(accessType)) {
        return new ReadWriteMemcachedCollectionRegionAccessStrategy(this, settings);
    } else if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new NonStrictReadWriteMemcachedCollectionRegionAccessStrategy(this, settings);
    } else if (AccessType.TRANSACTIONAL.equals(accessType)) {
        return new TransactionalMemcachedCollectionRegionAccessStrategy(this, cache, settings);
    } else {
        throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
    }
}

From source file:com.googlecode.hibernate.memcached.region.MemcachedEntityRegion.java

License:Apache License

public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {

    if (AccessType.READ_ONLY.equals(accessType)) {
        if (metadata.isMutable()) {
            log.warn("read-only cache configured for mutable entity [" + getName() + "]");
        }//from   w  ww .j av  a2  s.  c  om
        return new ReadOnlyMemcachedEntityRegionAccessStrategy(this, settings);
    } else if (AccessType.READ_WRITE.equals(accessType)) {
        return new ReadWriteMemcachedEntityRegionAccessStrategy(this, settings);
    } else if (AccessType.NONSTRICT_READ_WRITE.equals(accessType)) {
        return new NonStrictReadWriteMemcachedEntityRegionAccessStrategy(this, settings);
    } else if (AccessType.TRANSACTIONAL.equals(accessType)) {
        return new TransactionalMemcachedEntityRegionAccessStrategy(this, cache, settings);
    } else {
        throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
    }
}

From source file:com.hazelcast.hibernate.region.HazelcastCollectionRegion.java

License:Open Source License

public CollectionRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to build CollectionRegionAccessStrategy. This can't happen!");
    }//  w  w w .  j ava  2  s. c om
    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));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType " + accessType
            + " while attempting to build CollectionRegionAccessStrategy.");
}

From source file:com.hazelcast.hibernate.region.HazelcastEntityRegion.java

License:Open Source License

public EntityRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to determine a proper EntityRegionAccessStrategy. This can't happen!");
    }/*  w w w  .j  av  a 2s .  c om*/
    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));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType \"" + accessType
            + "\" while attempting to build EntityRegionAccessStrategy.");
}

From source file:com.hazelcast.hibernate.region.HazelcastNaturalIdRegion.java

License:Open Source License

public NaturalIdRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to determine a proper NaturalIdRegionAccessStrategy. "
                        + "This can't happen!");
    }// w w w . ja  va  2 s .co  m
    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));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType \"" + accessType
            + "\" while attempting to build EntityRegionAccessStrategy.");
}

From source file:com.hazelcast.hibernate4.region.HazelcastNaturalIdRegion.java

License:Open Source License

public NaturalIdRegionAccessStrategy buildAccessStrategy(final AccessType accessType) throws CacheException {
    if (null == accessType) {
        throw new CacheException(
                "Got null AccessType while attempting to determine a proper NaturalIdRegionAccessStrategy. This can't happen!");
    }//from  w w  w.  ja  v  a2 s .co  m
    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));
    }
    if (AccessType.TRANSACTIONAL.equals(accessType)) {
        throw new CacheException("Transactional access is not currently supported by Hazelcast.");
    }
    throw new CacheException("Got unknown AccessType \"" + accessType
            + "\" while attempting to build EntityRegionAccessStrategy.");
}

From source file:org.apache.ignite.cache.hibernate.GridHibernateL2CacheTransactionalSelfTest.java

License:Apache License

/** {@inheritDoc} */
@Override
protected AccessType[] accessTypes() {
    return new AccessType[] { AccessType.TRANSACTIONAL };
}

From source file:org.fgsake.hibernate.cache.couchbase.internal.CouchbaseTransactionalDataRegion.java

License:Apache License

protected AccessType translateAccessType(AccessType accessType) {
    if (accessType == AccessType.TRANSACTIONAL) {
        throw new CacheException("Access type " + accessType + " isn't supported");
    } else if (accessType == AccessType.NONSTRICT_READ_WRITE && ignoreNonstrict) {
        return AccessType.READ_WRITE;
    }//from  w w  w .j  a v a 2 s .  c  o  m
    return accessType;
}

From source file:org.infinispan.hibernate.cache.commons.impl.BaseRegion.java

License:LGPL

protected void checkAccessType(AccessType accessType) {
    if (accessType == AccessType.TRANSACTIONAL
            && !cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) {
        log.transactionalStrategyNonTransactionalCache();
    } else if (accessType == AccessType.READ_WRITE
            && cache.getCacheConfiguration().transaction().transactionMode().isTransactional()) {
        log.readWriteStrategyTransactionalCache();
    }//from   w  ww  .j  av a2s. com
}

From source file:org.infinispan.hibernate.cache.commons.InfinispanRegionFactory.java

License:LGPL

@Override
public AccessType getDefaultAccessType() {
    return AccessType.TRANSACTIONAL;
}