Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-7350 read-only entities can not be deleted from 2LC
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.hibernate.cache.infinispan.entity; | ||
|
||
import org.hibernate.cache.CacheException; | ||
import org.hibernate.cache.spi.access.SoftLock; | ||
|
||
/** | ||
* A specialization of {@link TransactionalAccess} that ensures we never update data. Infinispan | ||
* access is always transactional. | ||
* | ||
* @author Chris Bredesen | ||
* @author Galder Zamarreño | ||
* @since 3.5 | ||
*/ | ||
class ReadOnlyAccess extends TransactionalAccess { | ||
|
||
ReadOnlyAccess(EntityRegionImpl region) { | ||
super(region); | ||
} | ||
|
||
@Override | ||
public boolean update(Object key, Object value, Object currentVersion, | ||
Object previousVersion) throws CacheException { | ||
throw new UnsupportedOperationException("Illegal attempt to edit read only item"); | ||
} | ||
|
||
@Override | ||
public boolean afterUpdate(Object key, Object value, Object currentVersion, | ||
Object previousVersion, SoftLock lock) throws CacheException { | ||
throw new UnsupportedOperationException("Illegal attempt to edit read only item"); | ||
} | ||
|
||
} |