diff --git a/hibernate-entitymanager/src/matrix/java/org/hibernate/ejb/test/lock/LockTest.java b/hibernate-entitymanager/src/matrix/java/org/hibernate/ejb/test/lock/LockTest.java index b984ce03cc..e27391f301 100644 --- a/hibernate-entitymanager/src/matrix/java/org/hibernate/ejb/test/lock/LockTest.java +++ b/hibernate-entitymanager/src/matrix/java/org/hibernate/ejb/test/lock/LockTest.java @@ -60,7 +60,7 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase { Query query = em.createNamedQuery( "getAll" ); query.setLockMode( LockModeType.PESSIMISTIC_READ ); int timeout = ((QueryImpl)(((org.hibernate.ejb.QueryImpl)query).getHibernateQuery())).getLockOptions().getTimeOut(); - assertEquals( 3, timeout ); + assertEquals( 3000, timeout ); } @Override diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java new file mode 100644 index 0000000000..b5724117ab --- /dev/null +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java @@ -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"); + } + +} \ No newline at end of file