diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java index 3fba8c9456..4156381da6 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java @@ -216,7 +216,7 @@ public class BatchFetchQueue { } private boolean isCached(EntityKey entityKey, EntityPersister persister) { - if ( persister.hasCache() ) { + if ( context.getSession().getCacheMode().isGetEnabled() && persister.hasCache() ) { final CacheKey key = context.getSession().generateCacheKey( entityKey.getIdentifier(), persister.getIdentifierType(), @@ -329,7 +329,7 @@ public class BatchFetchQueue { } private boolean isCached(Serializable collectionKey, CollectionPersister persister) { - if ( persister.hasCache() ) { + if ( context.getSession().getCacheMode().isGetEnabled() && persister.hasCache() ) { CacheKey cacheKey = context.getSession().generateCacheKey( collectionKey, persister.getKeyType(), diff --git a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java index 19a51904cf..05ccd144b7 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java @@ -1592,7 +1592,7 @@ public abstract class Loader { ); // see if the entity defines reference caching, and if so use the cached reference (if one). - if ( persister.canUseReferenceCacheEntries() ) { + if ( session.getCacheMode().isGetEnabled() && persister.canUseReferenceCacheEntries() ) { final Object cachedEntry = CacheHelper.fromSharedCache( session, session.generateCacheKey( diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 4c8c73b79a..05821d2170 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -1220,7 +1220,7 @@ public abstract class AbstractEntityPersister LOG.tracev( "Initializing lazy properties of: {0}, field access: {1}", MessageHelper.infoString( this, id, getFactory() ), fieldName ); } - if ( hasCache() ) { + if ( session.getCacheMode().isGetEnabled() && hasCache() ) { final CacheKey cacheKey = session.generateCacheKey( id, getIdentifierType(), getEntityName() ); final Object ce = CacheHelper.fromSharedCache( session, cacheKey, getCacheAccessStrategy() ); if ( ce != null ) { @@ -4299,7 +4299,7 @@ public abstract class AbstractEntityPersister } // check to see if it is in the second-level cache - if ( hasCache() ) { + if ( session.getCacheMode().isGetEnabled() && hasCache() ) { final CacheKey ck = session.generateCacheKey( id, getIdentifierType(), getRootEntityName() ); final Object ce = CacheHelper.fromSharedCache( session, ck, getCacheAccessStrategy() ); if ( ce != null ) {