HHH-13627 Invalidate cache on update for CacheMode GET and IGNORE
This commit is contained in:
parent
af074e2b1d
commit
3f029e1dde
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.action.internal;
|
package org.hibernate.action.internal;
|
||||||
|
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
|
import org.hibernate.CacheMode;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.cache.CacheException;
|
import org.hibernate.cache.CacheException;
|
||||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||||
|
@ -195,7 +196,7 @@ public class EntityUpdateAction extends EntityAction {
|
||||||
final EntityPersister persister = getPersister();
|
final EntityPersister persister = getPersister();
|
||||||
if ( persister.canWriteToCache() ) {
|
if ( persister.canWriteToCache() ) {
|
||||||
final SharedSessionContractImplementor session = getSession();
|
final SharedSessionContractImplementor session = getSession();
|
||||||
if ( persister.isCacheInvalidationRequired() || entry.getStatus() != Status.MANAGED ) {
|
if ( isCacheInvalidationRequired( persister, session ) || entry.getStatus() != Status.MANAGED ) {
|
||||||
persister.getCacheAccessStrategy().remove( session, ck );
|
persister.getCacheAccessStrategy().remove( session, ck );
|
||||||
}
|
}
|
||||||
else if ( session.getCacheMode().isPutEnabled() ) {
|
else if ( session.getCacheMode().isPutEnabled() ) {
|
||||||
|
@ -215,6 +216,13 @@ public 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 IGNORE
|
||||||
|
return persister.isCacheInvalidationRequired() || session.getCacheMode() == CacheMode.GET || session.getCacheMode() == CacheMode.IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
private void handleGeneratedProperties(EntityEntry entry) {
|
private void handleGeneratedProperties(EntityEntry entry) {
|
||||||
final EntityPersister persister = getPersister();
|
final EntityPersister persister = getPersister();
|
||||||
final Object instance = getInstance();
|
final Object instance = getInstance();
|
||||||
|
|
Loading…
Reference in New Issue