HHH-7350 read-only entities can not be deleted from 2LC

This commit is contained in:
Strong Liu 2012-05-25 13:10:26 +08:00
parent 27df736412
commit a203ea65aa
8 changed files with 10 additions and 83 deletions

View File

@ -75,19 +75,13 @@ public class ReadOnlyEhcacheCollectionRegionAccessStrategy
}
}
/**
* Throws UnsupportedOperationException since this cache is read-only
*
* @throws UnsupportedOperationException always
*/
public SoftLock lockItem(Object key, Object version) throws UnsupportedOperationException {
throw new UnsupportedOperationException( "Can't write to a readonly object" );
return null;
}
/**
* A no-op since this cache is read-only
*/
public void unlockItem(Object key, SoftLock lock) throws CacheException {
//throw new UnsupportedOperationException("Can't write to a readonly object");
}
}

View File

@ -78,20 +78,15 @@ public class ReadOnlyEhcacheEntityRegionAccessStrategy extends AbstractEhcacheAc
}
}
/**
* Throws UnsupportedOperationException since this cache is read-only
*
* @throws UnsupportedOperationException always
*/
public SoftLock lockItem(Object key, Object version) throws UnsupportedOperationException {
throw new UnsupportedOperationException( "Can't write to a readonly object" );
return null;
}
/**
* A no-op since this cache is read-only
*/
public void unlockItem(Object key, SoftLock lock) throws CacheException {
//throw new UnsupportedOperationException("Can't write to a readonly object");
evict( key );
}
/**

View File

@ -75,20 +75,15 @@ public class ReadOnlyEhcacheNaturalIdRegionAccessStrategy
}
}
/**
* Throws UnsupportedOperationException since this cache is read-only
*
* @throws UnsupportedOperationException always
*/
public SoftLock lockItem(Object key, Object version) throws UnsupportedOperationException {
throw new UnsupportedOperationException( "Can't write to a readonly object" );
return null;
}
/**
* A no-op since this cache is read-only
*/
public void unlockItem(Object key, SoftLock lock) throws CacheException {
//throw new UnsupportedOperationException("Can't write to a readonly object");
region.remove( key );
}
/**

View File

@ -16,25 +16,6 @@ class ReadOnlyAccess extends TransactionalAccess {
super( naturalIdRegion );
}
@Override
public SoftLock lockItem(Object key, Object version) throws CacheException {
throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
}
@Override
public SoftLock lockRegion() throws CacheException {
throw new UnsupportedOperationException( "Illegal attempt to edit read only item" );
}
@Override
public void unlockItem(Object key, SoftLock lock) throws CacheException {
log.error( "Illegal attempt to edit read only item" );
}
@Override
public void unlockRegion(SoftLock lock) throws CacheException {
log.error( "Illegal attempt to edit read only item" );
}
@Override
public boolean update(Object key, Object value) throws CacheException {

View File

@ -31,7 +31,9 @@ import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
*/
class BaseCollectionRegionAccessStrategy extends BaseRegionAccessStrategy implements CollectionRegionAccessStrategy {
private final CollectionRegionImpl region;
BaseCollectionRegionAccessStrategy(CollectionRegionImpl region) {
this.region = region;
}
@Override
protected BaseGeneralDataRegion getInternalRegion() {
return region;
@ -46,8 +48,4 @@ class BaseCollectionRegionAccessStrategy extends BaseRegionAccessStrategy implem
public CollectionRegion getRegion() {
return region;
}
BaseCollectionRegionAccessStrategy(CollectionRegionImpl region) {
this.region = region;
}
}

View File

@ -33,25 +33,7 @@ import org.hibernate.internal.CoreMessageLogger;
* @author Strong Liu
*/
class ReadOnlyCollectionRegionAccessStrategy extends BaseCollectionRegionAccessStrategy {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class, ReadOnlyCollectionRegionAccessStrategy.class.getName()
);
ReadOnlyCollectionRegionAccessStrategy(CollectionRegionImpl region) {
super( region );
}
@Override
public void unlockItem(Object key, SoftLock lock) throws CacheException {
LOG.invalidEditOfReadOnlyItem( key );
}
@Override
public SoftLock lockItem(Object key, Object version) throws CacheException {
LOG.invalidEditOfReadOnlyItem( key );
throw new UnsupportedOperationException( "Can't write to a readonly object" );
}
}

View File

@ -54,18 +54,9 @@ class ReadOnlyEntityRegionAccessStrategy extends BaseEntityRegionAccessStrategy
return true;
}
/**
* This cache is asynchronous hence a no-op
*/
@Override
public void unlockItem(Object key, SoftLock lock) throws CacheException {
LOG.invalidEditOfReadOnlyItem( key );
}
@Override
public SoftLock lockItem(Object key, Object version) throws CacheException {
LOG.invalidEditOfReadOnlyItem( key );
throw new UnsupportedOperationException( "Can't write to a readonly object" );
evict( key );
}
/**

View File

@ -43,15 +43,6 @@ class ReadOnlyNaturalIdRegionAccessStrategy extends BaseNaturalIdRegionAccessStr
@Override
public void unlockItem(Object key, SoftLock lock) throws CacheException {
LOG.invalidEditOfReadOnlyItem( key );
evict( key );
}
@Override
public SoftLock lockItem(Object key, Object version) throws CacheException {
LOG.invalidEditOfReadOnlyItem( key );
throw new UnsupportedOperationException( "Can't write to a readonly object" );
}
}