public class HibernateTransactionalAccessStrategy extends HibernateAccessStrategyAdapter
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
限定符和类型 | 方法和说明 |
---|---|
boolean |
afterInsert(Object key,
Object val)
Called after Hibernate inserted object in the database and transaction successfully completed.
|
boolean |
afterUpdate(Object key,
Object val)
Called after Hibernate updated object in the database and transaction successfully completed.
|
@Nullable Object |
get(Object key) |
boolean |
insert(Object key,
Object val)
Called after Hibernate inserted object in the database but before transaction completed.
|
void |
lock(Object key)
Called during database transaction execution before Hibernate attempts to update or remove given key.
|
void |
putFromLoad(Object key,
Object val)
Puts in cache value loaded from the database.
|
void |
remove(Object key)
Called after Hibernate removed object from database but before transaction completed.
|
void |
unlock(Object key)
Called after Hibernate failed to update or successfully removed given key.
|
boolean |
update(Object key,
Object val)
Called after Hibernate updated object in the database but before transaction completed.
|
evict, evict, evictAll, evictAll, lockRegion, putFromLoad, removeAll, unlockRegion
@Nullable public @Nullable Object get(Object key)
get
在类中 HibernateAccessStrategyAdapter
key
- Key.public void putFromLoad(Object key, Object val)
putFromLoad
在类中 HibernateAccessStrategyAdapter
key
- Key.val
- Value.public void lock(Object key)
lock
在类中 HibernateAccessStrategyAdapter
key
- Key.public void unlock(Object key)
unlock
在类中 HibernateAccessStrategyAdapter
key
- Key.public boolean update(Object key, Object val)
update
在类中 HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.public boolean afterUpdate(Object key, Object val)
afterUpdate
在类中 HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.public boolean insert(Object key, Object val)
insert
在类中 HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.public boolean afterInsert(Object key, Object val)
afterInsert
在类中 HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.public void remove(Object key)
remove
在类中 HibernateAccessStrategyAdapter
key
- Key,
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.8.0-SNAPSHOT Release Date : 四月 9 2019