diff --git a/hibernate-core/src/main/java/org/hibernate/Session.java b/hibernate-core/src/main/java/org/hibernate/Session.java index 43d21195a5..5c4ded41f0 100644 --- a/hibernate-core/src/main/java/org/hibernate/Session.java +++ b/hibernate-core/src/main/java/org/hibernate/Session.java @@ -205,6 +205,20 @@ public interface Session extends SharedSessionContract, EntityManager { */ CacheMode getCacheMode(); + /** + * The JPA-defined {@link CacheStoreMode}. + * + * @see #getCacheMode() + */ + CacheStoreMode getCacheStoreMode(); + + /** + * The JPA-defined {@link CacheRetrieveMode}. + * + * @see #getCacheMode() + */ + CacheRetrieveMode getCacheRetrieveMode(); + /** * Enable or disable writes to the second-level cache. * diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java index 3be5022103..3121a4614b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java @@ -202,6 +202,16 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { return delegate.getCacheMode(); } + @Override + public CacheRetrieveMode getCacheRetrieveMode() { + return delegate.getCacheRetrieveMode(); + } + + @Override + public CacheStoreMode getCacheStoreMode() { + return delegate.getCacheStoreMode(); + } + @Override public void setCacheMode(CacheMode cm) { delegate.setCacheMode( cm ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionLazyDelegator.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionLazyDelegator.java index 65d44606f0..828fc43a97 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionLazyDelegator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionLazyDelegator.java @@ -111,6 +111,16 @@ public class SessionLazyDelegator implements Session { this.lazySession.get().setCacheStoreMode( cacheStoreMode ); } + @Override + public CacheStoreMode getCacheStoreMode() { + return this.lazySession.get().getCacheStoreMode(); + } + + @Override + public CacheRetrieveMode getCacheRetrieveMode() { + return this.lazySession.get().getCacheRetrieveMode(); + } + @Override public CacheMode getCacheMode() { return this.lazySession.get().getCacheMode(); diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index a6451a90c8..d0ba999274 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -1836,6 +1836,16 @@ public class SessionImpl persistenceContext.setReadOnly( entity, readOnly ); } + @Override + public CacheStoreMode getCacheStoreMode() { + return getCacheMode().getJpaStoreMode(); + } + + @Override + public CacheRetrieveMode getCacheRetrieveMode() { + return getCacheMode().getJpaRetrieveMode(); + } + @Override public void setCacheStoreMode(CacheStoreMode cacheStoreMode) { setCacheMode( fromJpaModes( getCacheMode().getJpaRetrieveMode(), cacheStoreMode ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java b/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java index be41fe7b9a..2658c26ff4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java @@ -285,6 +285,16 @@ public interface SelectionQuery extends CommonQueryContract { */ CacheMode getCacheMode(); + /** + * @see #getCacheMode() + */ + CacheStoreMode getCacheStoreMode(); + + /** + * @see #getCacheMode() + */ + CacheRetrieveMode getCacheRetrieveMode(); + /** * Set the current {@link CacheMode} in effect for this query. * diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractSelectionQuery.java b/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractSelectionQuery.java index 71d539b133..a2989d5f3b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractSelectionQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractSelectionQuery.java @@ -686,6 +686,16 @@ public abstract class AbstractSelectionQuery return getQueryOptions().getCacheMode(); } + @Override + public CacheStoreMode getCacheStoreMode() { + return getCacheMode().getJpaStoreMode(); + } + + @Override + public CacheRetrieveMode getCacheRetrieveMode() { + return getCacheMode().getJpaRetrieveMode(); + } + @Override public SelectionQuery setCacheMode(CacheMode cacheMode) { getQueryOptions().setCacheMode( cacheMode );