HHH-15702 add Session.setCacheRetrieveMode, Session.setCacheStoreMode
This commit is contained in:
parent
5c90779a02
commit
778675b867
|
@ -8,6 +8,8 @@ package org.hibernate;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.CacheRetrieveMode;
|
||||
import jakarta.persistence.CacheStoreMode;
|
||||
import jakarta.persistence.PessimisticLockScope;
|
||||
import org.hibernate.graph.RootGraph;
|
||||
import org.hibernate.query.Query;
|
||||
|
@ -203,6 +205,24 @@ public interface Session extends SharedSessionContract, EntityManager {
|
|||
*/
|
||||
CacheMode getCacheMode();
|
||||
|
||||
/**
|
||||
* Enable or disable writes to the second-level cache.
|
||||
*
|
||||
* @param cacheStoreMode a JPA-defined {@link CacheStoreMode}
|
||||
*
|
||||
* @see #setCacheMode(CacheMode)
|
||||
*/
|
||||
void setCacheStoreMode(CacheStoreMode cacheStoreMode);
|
||||
|
||||
/**
|
||||
* Enable or disable reads from the second-level cache.
|
||||
*
|
||||
* @param cacheRetrieveMode a JPA-defined {@link CacheRetrieveMode}
|
||||
*
|
||||
* @see #setCacheMode(CacheMode)
|
||||
*/
|
||||
void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode);
|
||||
|
||||
/**
|
||||
* Get the session factory which created this session.
|
||||
*
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.util.Set;
|
|||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import jakarta.persistence.CacheRetrieveMode;
|
||||
import jakarta.persistence.CacheStoreMode;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.Filter;
|
||||
import org.hibernate.FlushMode;
|
||||
|
@ -205,6 +207,16 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
delegate.setCacheMode( cm );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheStoreMode(CacheStoreMode cacheStoreMode) {
|
||||
delegate.setCacheStoreMode( cacheStoreMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) {
|
||||
delegate.setCacheRetrieveMode( cacheRetrieveMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled) {
|
||||
delegate.setCriteriaCopyTreeEnabled( jpaCriteriaCopyComplianceEnabled );
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import jakarta.persistence.CacheRetrieveMode;
|
||||
import jakarta.persistence.CacheStoreMode;
|
||||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.Filter;
|
||||
import org.hibernate.FlushMode;
|
||||
|
@ -99,6 +101,16 @@ public class SessionLazyDelegator implements Session {
|
|||
this.lazySession.get().setCacheMode( cacheMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) {
|
||||
this.lazySession.get().setCacheRetrieveMode( cacheRetrieveMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheStoreMode(CacheStoreMode cacheStoreMode) {
|
||||
this.lazySession.get().setCacheStoreMode( cacheStoreMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheMode getCacheMode() {
|
||||
return this.lazySession.get().getCacheMode();
|
||||
|
@ -275,7 +287,7 @@ public class SessionLazyDelegator implements Session {
|
|||
this.lazySession.get().lock( object, lockMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated
|
||||
public void lock(String entityName, Object object, LockMode lockMode) {
|
||||
this.lazySession.get().lock( entityName, object, lockMode );
|
||||
}
|
||||
|
|
|
@ -152,6 +152,7 @@ import jakarta.persistence.PersistenceException;
|
|||
import jakarta.persistence.TransactionRequiredException;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
|
||||
import static org.hibernate.CacheMode.fromJpaModes;
|
||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_SCOPE;
|
||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_TIMEOUT;
|
||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_SHARED_CACHE_RETRIEVE_MODE;
|
||||
|
@ -1835,6 +1836,16 @@ public class SessionImpl
|
|||
persistenceContext.setReadOnly( entity, readOnly );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheStoreMode(CacheStoreMode cacheStoreMode) {
|
||||
setCacheMode( fromJpaModes( getCacheMode().getJpaRetrieveMode(), cacheStoreMode ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) {
|
||||
setCacheMode( fromJpaModes( cacheRetrieveMode, getCacheMode().getJpaStoreMode() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterScrollOperation() {
|
||||
// nothing to do in a stateful session
|
||||
|
@ -2119,18 +2130,18 @@ public class SessionImpl
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated @SuppressWarnings("deprecation")
|
||||
public boolean getScope() {
|
||||
return lockOptions.getScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated @SuppressWarnings("deprecation")
|
||||
public LockRequest setScope(boolean scope) {
|
||||
lockOptions.setScope( scope );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @Deprecated @SuppressWarnings("deprecation")
|
||||
public void lock(String entityName, Object object) throws HibernateException {
|
||||
fireLock( entityName, object, lockOptions );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue