HHH-13627 Invalidate cache on update for CacheMode GET and IGNORE
This commit is contained in:
parent
f2b07e3f46
commit
f3e039da0a
|
@ -9,6 +9,7 @@ package org.hibernate.action.internal;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.cache.CacheException;
|
||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
|
@ -186,8 +187,8 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
}
|
||||
|
||||
if ( persister.canWriteToCache() ) {
|
||||
if ( persister.isCacheInvalidationRequired() || entry.getStatus()!= Status.MANAGED ) {
|
||||
persister.getCacheAccessStrategy().remove( session, ck);
|
||||
if ( isCacheInvalidationRequired( persister, session ) || entry.getStatus() != Status.MANAGED ) {
|
||||
persister.getCacheAccessStrategy().remove( session, ck );
|
||||
}
|
||||
else if ( session.getCacheMode().isPutEnabled() ) {
|
||||
//TODO: inefficient if that cache is just going to ignore the updated state!
|
||||
|
@ -219,6 +220,13 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isCacheInvalidationRequired(
|
||||
EntityPersister persister,
|
||||
SharedSessionContractImplementor session) {
|
||||
// the cache has to be invalidated when CacheMode is equal to GET or IGNOREgfa
|
||||
return persister.isCacheInvalidationRequired() || session.getCacheMode() == CacheMode.GET || session.getCacheMode() == CacheMode.IGNORE;
|
||||
}
|
||||
|
||||
private boolean cacheUpdate(EntityPersister persister, Object previousVersion, Object ck) {
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue