public class HibernateTransactionalAccessStrategy extends HibernateAccessStrategyAdapter
AccessType.TRANSACTIONAL cache access strategy.
It is supposed that this strategy is used in JTA environment and Hibernate and
IgniteInternalCache corresponding to the L2 cache region are configured to use the same transaction manager.
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 Ignite as L2 cache provider. -->
<property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
<!-- Specify entity. -->
<mapping class="com.example.Entity"/>
<!-- Enable L2 cache with transactional access strategy for entity. -->
<class-cache class="com.example.Entity" usage="transactional"/>
</hibernate-configuration>
Also cache access strategy can be set using annotations:
@javax.persistence.Entity
@javax.persistence.Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class Entity { ... }
cache, ignite, log| Constructor and Description |
|---|
HibernateTransactionalAccessStrategy(Ignite ignite,
org.apache.ignite.internal.processors.cache.IgniteInternalCache<Object,Object> cache) |
| 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, unlockRegion@Nullable protected Object get(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.get(java.lang.Object, long).get in class HibernateAccessStrategyAdapterkey - 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 HibernateAccessStrategyAdapterkey - 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 HibernateAccessStrategyAdapterkey - 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 HibernateAccessStrategyAdapterkey - Key.lock - The lock previously obtained from HibernateAccessStrategyAdapter.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 HibernateAccessStrategyAdapterkey - 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 HibernateAccessStrategyAdapterkey - Key.val - Value.lock - The lock previously obtained from HibernateAccessStrategyAdapter.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 HibernateAccessStrategyAdapterkey - 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 HibernateAccessStrategyAdapterkey - 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 HibernateAccessStrategyAdapterkey - Key,org.hibernate.cache.CacheException - If failed.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016