HHH-6827 correct testing 2L cache impl, mostly are copied from ehcache impl

This commit is contained in:
Strong Liu 2011-11-21 20:09:15 +08:00
parent 6c6e9669c1
commit 15a46a9661
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,27 @@
package org.hibernate.testing.cache;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.CollectionRegion;
import org.hibernate.cache.spi.access.SoftLock;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
class TransactionalCollectionRegionAccessStrategy extends BaseCollectionRegionAccessStrategy {
TransactionalCollectionRegionAccessStrategy(CollectionRegionImpl region) {
super( region );
}
/**
* {@inheritDoc}
*/
@Override
public void remove(Object key) throws CacheException {
evict( key );
}
}

View File

@ -0,0 +1,45 @@
package org.hibernate.testing.cache;
import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.access.SoftLock;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
class TransactionalEntityRegionAccessStrategy extends BaseEntityRegionAccessStrategy {
TransactionalEntityRegionAccessStrategy(EntityRegionImpl region) {
super( region );
}
/**
* {@inheritDoc}
*/
public boolean afterInsert(Object key, Object value, Object version) {
return false;
}
/**
* {@inheritDoc}
*/
public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) {
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void remove(Object key) throws CacheException {
evict( key );
}
/**
* {@inheritDoc}
*/
public boolean update(Object key, Object value, Object currentVersion,
Object previousVersion) throws CacheException {
return insert( key, value, currentVersion );
}
}