Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

HHH-7350 readonly entity can't be deleted from 2LC #341

Closed
wants to merge 3 commits into from

3 participants

@stliu
Collaborator

No description provided.

andrigtmiller and others added some commits
@andrigtmiller andrigtmiller HHH-7350 - removed overridden methods in ReadOnlyAccess lock/unlock a…
…n instance and/or region of the cache, since inserts and deletes are allowed with a CacheConcurrencyStrategy of READ_ONLY.
9dcdc83
@andrigtmiller andrigtmiller HHH-7350 - Fixed up the unit tests, to allow the lock of the cache re…
…gion for an access strategy of READ_ONLY.
5496ca0
@stliu stliu HHH-7350 read-only entities can not be deleted from 2LC d6a63db
@galderz
Collaborator

Hmm, the Infinispan part is already solved: 61a8416

I don't know about the rest.

@stliu stliu closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 24, 2012
  1. @andrigtmiller

    HHH-7350 - removed overridden methods in ReadOnlyAccess lock/unlock a…

    andrigtmiller authored
    …n instance and/or region of the cache, since inserts and deletes are allowed with a CacheConcurrencyStrategy of READ_ONLY.
  2. @andrigtmiller

    HHH-7350 - Fixed up the unit tests, to allow the lock of the cache re…

    andrigtmiller authored
    …gion for an access strategy of READ_ONLY.
Commits on May 25, 2012
  1. @stliu
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 142 deletions.
  1. +1 −7 .../main/java/org/hibernate/cache/ehcache/internal/strategy/ReadOnlyEhcacheCollectionRegionAccessStrategy.java
  2. +2 −7 .../src/main/java/org/hibernate/cache/ehcache/internal/strategy/ReadOnlyEhcacheEntityRegionAccessStrategy.java
  3. +2 −7 ...c/main/java/org/hibernate/cache/ehcache/internal/strategy/ReadOnlyEhcacheNaturalIdRegionAccessStrategy.java
  4. +0 −17 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java
  5. +1 −17 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java
  6. +0 −19 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/naturalid/ReadOnlyAccess.java
  7. +2 −5 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/EntityRegionImplTestCase.java
  8. +0 −20 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/ReadOnlyExtraAPITestCase.java
  9. +3 −5 hibernate-testing/src/main/java/org/hibernate/testing/cache/BaseCollectionRegionAccessStrategy.java
  10. +0 −18 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyCollectionRegionAccessStrategy.java
  11. +1 −10 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyEntityRegionAccessStrategy.java
  12. +1 −10 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyNaturalIdRegionAccessStrategy.java
View
8 ...in/java/org/hibernate/cache/ehcache/internal/strategy/ReadOnlyEhcacheCollectionRegionAccessStrategy.java
@@ -75,19 +75,13 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
}
}
- /**
- * 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
9 ...c/main/java/org/hibernate/cache/ehcache/internal/strategy/ReadOnlyEhcacheEntityRegionAccessStrategy.java
@@ -78,20 +78,15 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
}
}
- /**
- * 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
9 ...ain/java/org/hibernate/cache/ehcache/internal/strategy/ReadOnlyEhcacheNaturalIdRegionAccessStrategy.java
@@ -75,20 +75,15 @@ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object ve
}
}
- /**
- * 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
17 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java
@@ -18,25 +18,8 @@
* @since 3.5
*/
class ReadOnlyAccess extends TransactionalAccess {
- private static final Log log = LogFactory.getLog(ReadOnlyAccess.class);
-
ReadOnlyAccess(CollectionRegionImpl region) {
super(region);
}
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- throw new UnsupportedOperationException("Illegal attempt to edit read only item");
- }
-
- public SoftLock lockRegion() throws CacheException {
- throw new UnsupportedOperationException("Illegal attempt to edit read only region");
- }
-
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- log.error("Illegal attempt to edit read only item");
- }
-
- public void unlockRegion(SoftLock lock) throws CacheException {
- log.error("Illegal attempt to edit read only item");
- }
}
View
18 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java
@@ -21,22 +21,6 @@
super(region);
}
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- throw new UnsupportedOperationException("Illegal attempt to edit read only item");
- }
-
- public SoftLock lockRegion() throws CacheException {
- throw new UnsupportedOperationException("Illegal attempt to edit read only item");
- }
-
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- log.error("Illegal attempt to edit read only item");
- }
-
- public void unlockRegion(SoftLock lock) throws CacheException {
- log.error("Illegal attempt to edit read only item");
- }
-
@Override
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException {
throw new UnsupportedOperationException("Illegal attempt to edit read only item");
@@ -47,4 +31,4 @@ public boolean afterUpdate(Object key, Object value, Object currentVersion, Obje
throws CacheException {
throw new UnsupportedOperationException("Illegal attempt to edit read only item");
}
-}
+}
View
19 hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/naturalid/ReadOnlyAccess.java
@@ -16,25 +16,6 @@
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
7 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/EntityRegionImplTestCase.java
@@ -52,11 +52,8 @@ protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties p
EntityRegion region = regionFactory.buildEntityRegion("test", properties, null);
assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL)
.lockRegion());
- try {
- region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion();
- fail("Did not get READ_ONLY");
- } catch (UnsupportedOperationException good) {
- }
+
+ assertNull("Got READ_ONLY", region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion());
try {
region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE);
View
20 hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/entity/ReadOnlyExtraAPITestCase.java
@@ -41,26 +41,6 @@ protected AccessType getAccessType() {
}
@Override
- public void testLockItem() {
- try {
- getEntityAccessStrategy().lockItem( KEY, Integer.valueOf( 1 ) );
- fail( "Call to lockItem did not throw exception" );
- }
- catch (UnsupportedOperationException expected) {
- }
- }
-
- @Override
- public void testLockRegion() {
- try {
- getEntityAccessStrategy().lockRegion();
- fail( "Call to lockRegion did not throw exception" );
- }
- catch (UnsupportedOperationException expected) {
- }
- }
-
- @Override
public void testAfterUpdate() {
try {
getEntityAccessStrategy().afterUpdate(
View
8 hibernate-testing/src/main/java/org/hibernate/testing/cache/BaseCollectionRegionAccessStrategy.java
@@ -31,7 +31,9 @@
*/
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 @@ protected boolean isDefaultMinimalPutOverride() {
public CollectionRegion getRegion() {
return region;
}
-
- BaseCollectionRegionAccessStrategy(CollectionRegionImpl region) {
- this.region = region;
- }
}
View
18 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyCollectionRegionAccessStrategy.java
@@ -33,25 +33,7 @@
* @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
11 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyEntityRegionAccessStrategy.java
@@ -54,18 +54,9 @@ public boolean afterInsert(Object key, Object value, Object version) throws Cach
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
11 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyNaturalIdRegionAccessStrategy.java
@@ -43,15 +43,6 @@
@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" );
- }
-
-
-
}
Something went wrong with that request. Please try again.