Skip to content

Commit

Permalink
HHH-7350 read-only entities can not be deleted from 2LC
Browse files Browse the repository at this point in the history
  • Loading branch information
stliu committed May 30, 2012
1 parent a203ea6 commit fe7a5d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Expand Up @@ -60,7 +60,7 @@ public void testLockTimeoutASNamedQueryHint(){
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
Expand Down
@@ -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");
}

}

0 comments on commit fe7a5d7

Please sign in to comment.