public class HibernateReadOnlyAccessStrategy extends HibernateAccessStrategyAdapter
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 read-only access strategy for entity. --> <class-cache class="com.example.Entity" usage="read-only"/> </hibernate-configuration>Also cache access strategy can be set using annotations:
@javax.persistence.Entity @javax.persistence.Cacheable @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY) public class Entity { ... }
cache, ignite, log
Constructor and Description |
---|
HibernateReadOnlyAccessStrategy(Ignite ignite,
HibernateCacheProxy cache,
HibernateExceptionConverter eConverter) |
Modifier and Type | Method and Description |
---|---|
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.
|
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 |
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, get, lockRegion, putFromLoad, putFromLoad, removeAll, unlockRegion
public HibernateReadOnlyAccessStrategy(Ignite ignite, HibernateCacheProxy cache, HibernateExceptionConverter eConverter)
ignite
- Node.cache
- Cache.eConverter
- Exception converter.public boolean insert(Object key, Object val)
insert
in class HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.public boolean afterInsert(Object key, Object val)
afterInsert
in class HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.public void lock(Object key)
lock
in class HibernateAccessStrategyAdapter
key
- Key.public void unlock(Object key)
unlock
in class HibernateAccessStrategyAdapter
key
- Key.public void remove(Object key)
remove
in class HibernateAccessStrategyAdapter
key
- Key,public boolean update(Object key, Object val)
update
in class HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.public boolean afterUpdate(Object key, Object val)
afterUpdate
in class HibernateAccessStrategyAdapter
key
- Key.val
- Value.True
if operation updated cache.
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024