public abstract class GridHibernateAccessStrategyAdapter extends Object
RegionAccessStrategy
,
EntityRegionAccessStrategy
and CollectionRegionAccessStrategy
).
The expected sequences of steps related to various CRUD operations executed by Hibernate are:
Insert:
insert(java.lang.Object, java.lang.Object)
.afterInsert(java.lang.Object, java.lang.Object)
.afterInsert(java.lang.Object, java.lang.Object)
is not called.
Update:
lock(java.lang.Object)
.update(java.lang.Object, java.lang.Object)
.afterUpdate(java.lang.Object, java.lang.Object, org.hibernate.cache.spi.access.SoftLock)
.lock(java.lang.Object)
was called, but some other step fails and DB
transaction is rolled back then unlock(java.lang.Object, org.hibernate.cache.spi.access.SoftLock)
is called for all locked keys.
Delete:
lock(java.lang.Object)
for removing key.remove(java.lang.Object)
.unlock(java.lang.Object, org.hibernate.cache.spi.access.SoftLock)
.lock(java.lang.Object)
was called, but some other step fails and DB
transaction is rolled back then unlock(java.lang.Object, org.hibernate.cache.spi.access.SoftLock)
is called for all locked keys.
In case if custom SQL update query is executed Hibernate clears entire cache region, for this case operations sequence is:
lockRegion()
.removeAll()
.unlockRegion(org.hibernate.cache.spi.access.SoftLock)
.Modifier and Type | Field and Description |
---|---|
protected GridCache<Object,Object> |
cache |
protected Ignite |
ignite
Grid.
|
protected IgniteLogger |
log |
Modifier | Constructor and Description |
---|---|
protected |
GridHibernateAccessStrategyAdapter(Ignite ignite,
GridCache<Object,Object> cache) |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
afterInsert(Object key,
Object val)
Called after Hibernate inserted object in the database and transaction successfully completed.
|
protected abstract 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 void |
evict(Object key)
Called to remove object from cache without regard to transaction.
|
protected void |
evictAll()
Called to remove all data from cache without regard to transaction.
|
protected Object |
get(Object key)
Gets value from cache.
|
protected abstract boolean |
insert(Object key,
Object val)
Called after Hibernate inserted object in the database but before transaction completed.
|
protected abstract org.hibernate.cache.spi.access.SoftLock |
lock(Object key)
Called during database transaction execution before Hibernate attempts to update or remove given key.
|
protected org.hibernate.cache.spi.access.SoftLock |
lockRegion()
Called during database transaction execution before Hibernate executed
update operation which should invalidate entire cache region.
|
protected void |
putFromLoad(Object key,
Object val)
Puts in cache value loaded from the database.
|
protected void |
putFromLoad(Object key,
Object val,
boolean minimalPutOverride)
Puts in cache value loaded from the database.
|
protected abstract void |
remove(Object key)
Called after Hibernate removed object from database but before transaction completed.
|
protected void |
removeAll()
Called during database transaction execution to clear entire cache region after
Hibernate executed database update, but before transaction completed.
|
protected abstract void |
unlock(Object key,
org.hibernate.cache.spi.access.SoftLock lock)
Called after Hibernate failed to update or successfully removed given key.
|
protected void |
unlockRegion(org.hibernate.cache.spi.access.SoftLock lock)
Called after transaction clearing entire cache region completed.
|
protected abstract boolean |
update(Object key,
Object val)
Called after Hibernate updated object in the database but before transaction completed.
|
protected final Ignite ignite
protected final IgniteLogger log
@Nullable protected Object get(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.get(java.lang.Object, long)
.key
- Key.org.hibernate.cache.CacheException
- If failed.protected void putFromLoad(Object key, Object val, boolean minimalPutOverride) throws org.hibernate.cache.CacheException
RegionAccessStrategy.putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object)
.key
- Key.val
- Value.minimalPutOverride
- MinimalPut flagorg.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)
.key
- Key.val
- Value.org.hibernate.cache.CacheException
- If failed.@Nullable protected abstract org.hibernate.cache.spi.access.SoftLock lock(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.lockItem(java.lang.Object, java.lang.Object)
.key
- Key.null
.org.hibernate.cache.CacheException
- If failed.protected abstract 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)
.key
- Key.lock
- The lock previously obtained from lock(java.lang.Object)
org.hibernate.cache.CacheException
- If failed.protected abstract 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)
.key
- Key.val
- Value.True
if operation updated cache.org.hibernate.cache.CacheException
- If failed.protected abstract 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)
.key
- Key.val
- Value.lock
- The lock previously obtained from lock(java.lang.Object)
True
if operation updated cache.org.hibernate.cache.CacheException
- If failed.protected abstract 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)
.key
- Key.val
- Value.True
if operation updated cache.org.hibernate.cache.CacheException
- If failed.protected abstract 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)
.key
- Key.val
- Value.True
if operation updated cache.org.hibernate.cache.CacheException
- If failed.protected abstract void remove(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.remove(java.lang.Object)
.key
- Key,org.hibernate.cache.CacheException
- If failed.protected void evict(Object key) throws org.hibernate.cache.CacheException
RegionAccessStrategy.evict(java.lang.Object)
.key
- Key.org.hibernate.cache.CacheException
- If failed.protected void evictAll() throws org.hibernate.cache.CacheException
RegionAccessStrategy.evictAll()
.org.hibernate.cache.CacheException
- If failed.@Nullable protected org.hibernate.cache.spi.access.SoftLock lockRegion() throws org.hibernate.cache.CacheException
RegionAccessStrategy.lockRegion()
.null
.org.hibernate.cache.CacheException
- If failed.protected void unlockRegion(org.hibernate.cache.spi.access.SoftLock lock) throws org.hibernate.cache.CacheException
RegionAccessStrategy.unlockRegion(org.hibernate.cache.spi.access.SoftLock)
.lock
- The lock previously obtained from lockRegion()
org.hibernate.cache.CacheException
- If failed.protected final void removeAll() throws org.hibernate.cache.CacheException
RegionAccessStrategy.removeAll()
.org.hibernate.cache.CacheException
- If failed.
Follow @ApacheIgnite
Apache Ignite Fabric : ver. 1.0.0-RC1 Release Date : February 16 2015