public abstract class HibernateAccessStrategyAdapter extends Object
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)
.lock(java.lang.Object)
was called, but some other step fails and DB
transaction is rolled back then unlock(java.lang.Object)
is called for all locked keys.
Delete:
lock(java.lang.Object)
for removing key.remove(java.lang.Object)
.unlock(java.lang.Object)
.lock(java.lang.Object)
was called, but some other step fails and DB
transaction is rolled back then unlock(java.lang.Object)
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()
.Modifier and Type | Field and Description |
---|---|
protected HibernateCacheProxy |
cache |
protected Ignite |
ignite
Grid.
|
protected IgniteLogger |
log |
Modifier | Constructor and Description |
---|---|
protected |
HibernateAccessStrategyAdapter(Ignite ignite,
HibernateCacheProxy cache,
HibernateExceptionConverter eConverter) |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
afterInsert(Object key,
Object val)
Called after Hibernate inserted object in the database and transaction successfully completed.
|
abstract boolean |
afterUpdate(Object key,
Object val)
Called after Hibernate updated object in the database and transaction successfully completed.
|
static void |
evict(Ignite ignite,
HibernateCacheProxy cache,
Object key)
Called to remove object from cache without regard to transaction.
|
void |
evict(Object key)
Called to remove object from cache without regard to transaction.
|
void |
evictAll()
Called to remove all data from cache without regard to transaction.
|
static void |
evictAll(org.apache.ignite.internal.processors.cache.IgniteInternalCache<Object,Object> cache)
Called to remove all data from cache without regard to transaction.
|
@Nullable Object |
get(Object key) |
abstract boolean |
insert(Object key,
Object val)
Called after Hibernate inserted object in the database but before transaction completed.
|
abstract void |
lock(Object key)
Called during database transaction execution before Hibernate attempts to update or remove given key.
|
void |
lockRegion()
Called during database transaction execution before Hibernate executed
update operation which should invalidate entire cache region.
|
void |
putFromLoad(Object key,
Object val)
Puts in cache value loaded from the database.
|
void |
putFromLoad(Object key,
Object val,
boolean minimalPutOverride) |
abstract void |
remove(Object key)
Called after Hibernate removed object from database but before transaction completed.
|
void |
removeAll()
Called during database transaction execution to clear entire cache region after
Hibernate executed database update, but before transaction completed.
|
abstract void |
unlock(Object key)
Called after Hibernate failed to update or successfully removed given key.
|
void |
unlockRegion()
Called after transaction clearing entire cache region completed.
|
abstract boolean |
update(Object key,
Object val)
Called after Hibernate updated object in the database but before transaction completed.
|
protected final HibernateCacheProxy cache
protected final Ignite ignite
protected final IgniteLogger log
protected HibernateAccessStrategyAdapter(Ignite ignite, HibernateCacheProxy cache, HibernateExceptionConverter eConverter)
ignite
- Node.cache
- Cache.eConverter
- Exception converter.public void putFromLoad(Object key, Object val, boolean minimalPutOverride)
key
- Key.val
- Value.minimalPutOverride
- MinimalPut flagpublic void putFromLoad(Object key, Object val)
key
- Key.val
- Value.public abstract void lock(Object key)
key
- Key.public abstract void unlock(Object key)
key
- Key.public abstract boolean update(Object key, Object val)
key
- Key.val
- Value.True
if operation updated cache.public abstract boolean afterUpdate(Object key, Object val)
key
- Key.val
- Value.True
if operation updated cache.public abstract boolean insert(Object key, Object val)
key
- Key.val
- Value.True
if operation updated cache.public abstract boolean afterInsert(Object key, Object val)
key
- Key.val
- Value.True
if operation updated cache.public abstract void remove(Object key)
key
- Key,public void evict(Object key)
key
- Key.public void evictAll()
public final void removeAll()
public void lockRegion()
public void unlockRegion()
public static void evict(Ignite ignite, HibernateCacheProxy cache, Object key)
ignite
- Grid.cache
- Cache.key
- Key.public static void evictAll(org.apache.ignite.internal.processors.cache.IgniteInternalCache<Object,Object> cache) throws IgniteCheckedException
cache
- Cache.IgniteCheckedException
- If failed.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.2 Release Date : February 6 2019