public class GridHibernateReadWriteAccessStrategy extends GridHibernateAccessStrategyAdapter
AccessType.READ_WRITE cache access strategy.
Configuration of L2 cache and per-entity cache access strategy can be set in the Hibernate configuration file:
<hibernate-configuration>
<!-- Enable L2 cache. -->
<property name="cache.use_second_level_cache">true</property>
<!-- Use GridGain as L2 cache provider. -->
<property name="cache.region.factory_class">org.gridgain.grid.cache.hibernate.GridHibernateRegionFactory</property>
<!-- Specify entity. -->
<mapping class="com.example.Entity"/>
<!-- Enable L2 cache with read-write access strategy for entity. -->
<class-cache class="com.example.Entity" usage="read-write"/>
</hibernate-configuration>
Also cache access strategy can be set using annotations:
@javax.persistence.Entity
@javax.persistence.Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Entity { ... }
cache, grid, log| Modifier | Constructor and Description |
|---|---|
protected |
GridHibernateReadWriteAccessStrategy(org.gridgain.grid.Grid grid,
org.gridgain.grid.cache.GridCache<Object,Object> cache,
ThreadLocal txCtx) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
afterInsert(Object key,
Object val)
Called after Hibernate inserted object in the database and transaction successfully completed.
|
protected boolean |
afterUpdate(Object key,
Object val,
org.hibernate.cache.spi.access.SoftLock lock)
Called after Hibernate updated object in the database and transaction successfully completed.
|
protected Object |
get(Object key)
Gets value from cache.
|
protected boolean |
insert(Object key,
Object val)
Called after Hibernate inserted object in the database but before transaction completed.
|
protected org.hibernate.cache.spi.access.SoftLock |
lock(Object key)
Called during database transaction execution before Hibernate attempts to update or remove given key.
|
protected void |
putFromLoad(Object key,
Object val)
Puts in cache value loaded from the database.
|
protected void |
remove(Object key)
Called after Hibernate removed object from database but before transaction completed.
|
protected void |
unlock(Object key,
org.hibernate.cache.spi.access.SoftLock lock)
Called after Hibernate failed to update or successfully removed given key.
|
protected boolean |
update(Object key,
Object val)
Called after Hibernate updated object in the database but before transaction completed.
|
evict, evictAll, lockRegion, putFromLoad, removeAll, unlockRegionprotected GridHibernateReadWriteAccessStrategy(org.gridgain.grid.Grid grid,
org.gridgain.grid.cache.GridCache<Object,Object> cache,
ThreadLocal txCtx)
grid - Grid.cache - Cache.txCtx - Thread local instance used to track updates done during one Hibernate transaction.protected Object get(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.get(java.lang.Object, long).get in class GridHibernateAccessStrategyAdapterkey - Key.org.hibernate.cache.CacheException - If failed.protected void putFromLoad(Object key, Object val) throws org.hibernate.cache.CacheException
RegionAccessStrategy.putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object).putFromLoad in class GridHibernateAccessStrategyAdapterkey - Key.val - Value.org.hibernate.cache.CacheException - If failed.protected org.hibernate.cache.spi.access.SoftLock lock(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.lockItem(java.lang.Object, java.lang.Object).lock in class GridHibernateAccessStrategyAdapterkey - Key.null.org.hibernate.cache.CacheException - If failed.protected void unlock(Object key, org.hibernate.cache.spi.access.SoftLock lock) throws org.hibernate.cache.CacheException
RegionAccessStrategy.unlockItem(java.lang.Object, org.hibernate.cache.spi.access.SoftLock).unlock in class GridHibernateAccessStrategyAdapterkey - Key.lock - The lock previously obtained from GridHibernateAccessStrategyAdapter.lock(java.lang.Object)org.hibernate.cache.CacheException - If failed.protected boolean update(Object key, Object val) throws org.hibernate.cache.CacheException
EntityRegionAccessStrategy.update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object) and NaturalIdRegionAccessStrategy.update(java.lang.Object, java.lang.Object).update in class GridHibernateAccessStrategyAdapterkey - Key.val - Value.True if operation updated cache.org.hibernate.cache.CacheException - If failed.protected boolean afterUpdate(Object key, Object val, org.hibernate.cache.spi.access.SoftLock lock) throws org.hibernate.cache.CacheException
EntityRegionAccessStrategy.afterUpdate(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.spi.access.SoftLock) and NaturalIdRegionAccessStrategy.afterUpdate(java.lang.Object, java.lang.Object, org.hibernate.cache.spi.access.SoftLock).afterUpdate in class GridHibernateAccessStrategyAdapterkey - Key.val - Value.lock - The lock previously obtained from GridHibernateAccessStrategyAdapter.lock(java.lang.Object)True if operation updated cache.org.hibernate.cache.CacheException - If failed.protected boolean insert(Object key, Object val) throws org.hibernate.cache.CacheException
EntityRegionAccessStrategy.insert(java.lang.Object, java.lang.Object, java.lang.Object) and NaturalIdRegionAccessStrategy.insert(java.lang.Object, java.lang.Object).insert in class GridHibernateAccessStrategyAdapterkey - Key.val - Value.True if operation updated cache.org.hibernate.cache.CacheException - If failed.protected boolean afterInsert(Object key, Object val) throws org.hibernate.cache.CacheException
EntityRegionAccessStrategy.afterInsert(java.lang.Object, java.lang.Object, java.lang.Object) and NaturalIdRegionAccessStrategy.afterInsert(java.lang.Object, java.lang.Object).afterInsert in class GridHibernateAccessStrategyAdapterkey - Key.val - Value.True if operation updated cache.org.hibernate.cache.CacheException - If failed.protected void remove(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.remove(java.lang.Object).remove in class GridHibernateAccessStrategyAdapterkey - Key,org.hibernate.cache.CacheException - If failed.
GridGain Fabric : ver. 6.6.9-p1 Release Date : August 10 2016