HHH-16651 promote new operations from SessionBuilder to Session
setFetchBatchSize() and setSubselectFetchEnabled()
This commit is contained in:
parent
6215a8ef42
commit
3be2dc5978
|
@ -272,6 +272,59 @@ public interface Session extends SharedSessionContract, EntityManager {
|
||||||
*/
|
*/
|
||||||
void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode);
|
void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the maximum batch size for batch fetching associations by
|
||||||
|
* id in this session.
|
||||||
|
*
|
||||||
|
* @since 6.3
|
||||||
|
*/
|
||||||
|
int getFetchBatchSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the maximum batch size for batch fetching associations by
|
||||||
|
* id in this session. Override the
|
||||||
|
* {@linkplain org.hibernate.boot.spi.SessionFactoryOptions#getDefaultBatchFetchSize()
|
||||||
|
* factory-level} default controlled by the configuration property
|
||||||
|
* {@value org.hibernate.cfg.AvailableSettings#DEFAULT_BATCH_FETCH_SIZE}.
|
||||||
|
* <p>
|
||||||
|
* <ul>
|
||||||
|
* <li>If {@code batchSize>1}, then batch fetching is enabled.
|
||||||
|
* <li>If {@code batchSize<0}, the batch size is inherited from
|
||||||
|
* the factory-level setting.
|
||||||
|
* <li>Otherwise, batch fetching is disabled.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @param batchSize the maximum batch size for batch fetching
|
||||||
|
*
|
||||||
|
* @since 6.3
|
||||||
|
*
|
||||||
|
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_BATCH_FETCH_SIZE
|
||||||
|
*/
|
||||||
|
void setFetchBatchSize(int batchSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if subselect fetching is enabled in this session.
|
||||||
|
*
|
||||||
|
* @return {@code true} is subselect fetching is enabled
|
||||||
|
*
|
||||||
|
* @since 6.3
|
||||||
|
*/
|
||||||
|
boolean isSubselectFetchingEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable subselect fetching in this session. Override the
|
||||||
|
* {@linkplain org.hibernate.boot.spi.SessionFactoryOptions#isSubselectFetchEnabled()
|
||||||
|
* factory-level} default controlled by the configuration property
|
||||||
|
* {@value org.hibernate.cfg.AvailableSettings#USE_SUBSELECT_FETCH}.
|
||||||
|
*
|
||||||
|
* @param enabled {@code true} to enable subselect fetching
|
||||||
|
*
|
||||||
|
* @since 6.3
|
||||||
|
*
|
||||||
|
* @see org.hibernate.cfg.AvailableSettings#USE_SUBSELECT_FETCH
|
||||||
|
*/
|
||||||
|
void setSubselectFetchingEnabled(boolean enabled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the session factory which created this session.
|
* Get the session factory which created this session.
|
||||||
*
|
*
|
||||||
|
|
|
@ -145,8 +145,4 @@ public interface SessionBuilder {
|
||||||
* @see jakarta.persistence.PersistenceContextType
|
* @see jakarta.persistence.PersistenceContextType
|
||||||
*/
|
*/
|
||||||
SessionBuilder autoClose(boolean autoClose);
|
SessionBuilder autoClose(boolean autoClose);
|
||||||
|
|
||||||
SessionBuilder defaultBatchFetchSize(int batchSize);
|
|
||||||
|
|
||||||
SessionBuilder subselectFetchEnabled(boolean enabled);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,6 @@ public interface SharedSessionBuilder extends SessionBuilder {
|
||||||
*/
|
*/
|
||||||
SharedSessionBuilder flushMode();
|
SharedSessionBuilder flushMode();
|
||||||
|
|
||||||
SharedSessionBuilder defaultBatchFetchSize();
|
|
||||||
|
|
||||||
SharedSessionBuilder subselectFetchEnabled();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signifies that the autoClose flag from the original session should be used to create the new session.
|
* Signifies that the autoClose flag from the original session should be used to create the new session.
|
||||||
*
|
*
|
||||||
|
@ -88,10 +84,4 @@ public interface SharedSessionBuilder extends SessionBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
SharedSessionBuilder autoClose(boolean autoClose);
|
SharedSessionBuilder autoClose(boolean autoClose);
|
||||||
|
|
||||||
@Override
|
|
||||||
SharedSessionBuilder defaultBatchFetchSize(int batchSize);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
SharedSessionBuilder subselectFetchEnabled(boolean enabled);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,15 +185,16 @@ public interface SharedSessionContract extends QueryProducer, Closeable, Seriali
|
||||||
Integer getJdbcBatchSize();
|
Integer getJdbcBatchSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the session-level JDBC batch size. Overrides the
|
* Set the session-level JDBC batch size. Override the
|
||||||
* {@link org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize() factory-level}
|
* {@linkplain org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize() factory-level}
|
||||||
* JDBC batch size defined by the configuration property
|
* JDBC batch size controlled by the configuration property
|
||||||
* {@value org.hibernate.cfg.AvailableSettings#STATEMENT_BATCH_SIZE}.
|
* {@value org.hibernate.cfg.AvailableSettings#STATEMENT_BATCH_SIZE}.
|
||||||
*
|
*
|
||||||
* @param jdbcBatchSize the new session-level JDBC batch size
|
* @param jdbcBatchSize the new session-level JDBC batch size
|
||||||
*
|
*
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*
|
*
|
||||||
|
* @see org.hibernate.cfg.AvailableSettings#STATEMENT_BATCH_SIZE
|
||||||
* @see org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize
|
* @see org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize
|
||||||
* @see org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize
|
* @see org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1033,6 +1033,7 @@ public interface AvailableSettings {
|
||||||
* collections explicitly annotated {@code @BatchSize}.
|
* collections explicitly annotated {@code @BatchSize}.
|
||||||
*
|
*
|
||||||
* @see org.hibernate.annotations.BatchSize
|
* @see org.hibernate.annotations.BatchSize
|
||||||
|
* @see org.hibernate.Session#setFetchBatchSize(int)
|
||||||
* @see org.hibernate.boot.SessionFactoryBuilder#applyDefaultBatchFetchSize(int)
|
* @see org.hibernate.boot.SessionFactoryBuilder#applyDefaultBatchFetchSize(int)
|
||||||
*/
|
*/
|
||||||
String DEFAULT_BATCH_FETCH_SIZE = "hibernate.default_batch_fetch_size";
|
String DEFAULT_BATCH_FETCH_SIZE = "hibernate.default_batch_fetch_size";
|
||||||
|
@ -1045,6 +1046,7 @@ public interface AvailableSettings {
|
||||||
* explicitly annotated {@code @Fetch(SUBSELECT)}.
|
* explicitly annotated {@code @Fetch(SUBSELECT)}.
|
||||||
*
|
*
|
||||||
* @see org.hibernate.annotations.FetchMode#SUBSELECT
|
* @see org.hibernate.annotations.FetchMode#SUBSELECT
|
||||||
|
* @see org.hibernate.Session#setSubselectFetchingEnabled(boolean)
|
||||||
* @see org.hibernate.boot.SessionFactoryBuilder#applySubselectFetchEnabled(boolean)
|
* @see org.hibernate.boot.SessionFactoryBuilder#applySubselectFetchEnabled(boolean)
|
||||||
*/
|
*/
|
||||||
String USE_SUBSELECT_FETCH = "hibernate.use_subselect_fetch";
|
String USE_SUBSELECT_FETCH = "hibernate.use_subselect_fetch";
|
||||||
|
|
|
@ -122,16 +122,4 @@ public abstract class AbstractDelegatingSessionBuilder implements SessionBuilder
|
||||||
delegate.flushMode( flushMode );
|
delegate.flushMode( flushMode );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SessionBuilder defaultBatchFetchSize(int batchSize) {
|
|
||||||
delegate.defaultBatchFetchSize( batchSize );
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SessionBuilder subselectFetchEnabled(boolean enabled) {
|
|
||||||
delegate.subselectFetchEnabled( enabled );
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,28 +164,4 @@ public abstract class AbstractDelegatingSharedSessionBuilder implements SharedSe
|
||||||
delegate.jdbcTimeZone( timeZone );
|
delegate.jdbcTimeZone( timeZone );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilder defaultBatchFetchSize(int batchSize) {
|
|
||||||
delegate.defaultBatchFetchSize( batchSize );
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilder subselectFetchEnabled(boolean enabled) {
|
|
||||||
delegate.subselectFetchEnabled( enabled );
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilder defaultBatchFetchSize() {
|
|
||||||
delegate.defaultBatchFetchSize();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilder subselectFetchEnabled() {
|
|
||||||
delegate.subselectFetchEnabled();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1201,6 +1201,26 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
||||||
delegate.setJdbcBatchSize( jdbcBatchSize );
|
delegate.setJdbcBatchSize( jdbcBatchSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSubselectFetchingEnabled() {
|
||||||
|
return delegate.isSubselectFetchingEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSubselectFetchingEnabled(boolean enabled) {
|
||||||
|
delegate.setSubselectFetchingEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFetchBatchSize() {
|
||||||
|
return delegate.getFetchBatchSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFetchBatchSize(int batchSize) {
|
||||||
|
delegate.setFetchBatchSize( batchSize );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeZone getJdbcTimeZone() {
|
public TimeZone getJdbcTimeZone() {
|
||||||
return delegate.getJdbcTimeZone();
|
return delegate.getJdbcTimeZone();
|
||||||
|
|
|
@ -659,6 +659,26 @@ public class SessionLazyDelegator implements Session {
|
||||||
this.lazySession.get().setJdbcBatchSize( jdbcBatchSize );
|
this.lazySession.get().setJdbcBatchSize( jdbcBatchSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFetchBatchSize() {
|
||||||
|
return this.lazySession.get().getFetchBatchSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFetchBatchSize(int batchSize) {
|
||||||
|
this.lazySession.get().setFetchBatchSize( batchSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSubselectFetchingEnabled() {
|
||||||
|
return this.lazySession.get().isSubselectFetchingEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSubselectFetchingEnabled(boolean enabled) {
|
||||||
|
this.lazySession.get().setSubselectFetchingEnabled( enabled );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HibernateCriteriaBuilder getCriteriaBuilder() {
|
public HibernateCriteriaBuilder getCriteriaBuilder() {
|
||||||
return this.lazySession.get().getCriteriaBuilder();
|
return this.lazySession.get().getCriteriaBuilder();
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Interceptor;
|
import org.hibernate.Interceptor;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionBuilder;
|
|
||||||
import org.hibernate.SessionEventListener;
|
import org.hibernate.SessionEventListener;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.SessionFactoryObserver;
|
import org.hibernate.SessionFactoryObserver;
|
||||||
|
@ -1360,18 +1359,6 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SessionBuilder defaultBatchFetchSize(int batchSize) {
|
|
||||||
defaultBatchFetchSize = batchSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SessionBuilder subselectFetchEnabled(boolean enabled) {
|
|
||||||
subselectFetchEnabled = enabled;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SessionBuilderImpl flushMode(FlushMode flushMode) {
|
public SessionBuilderImpl flushMode(FlushMode flushMode) {
|
||||||
this.flushMode = flushMode;
|
this.flushMode = flushMode;
|
||||||
|
|
|
@ -1939,20 +1939,22 @@ public class SessionImpl
|
||||||
loadQueryInfluencers.disableFetchProfile( name );
|
loadQueryInfluencers.disableFetchProfile( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: unused for now, should we promote to Session?
|
@Override
|
||||||
public void setSubselectFetchingEnabled(boolean enabled) {
|
public void setSubselectFetchingEnabled(boolean enabled) {
|
||||||
loadQueryInfluencers.setSubselectFetchEnabled( enabled );
|
loadQueryInfluencers.setSubselectFetchEnabled( enabled );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSubselectFetchingEnabled() {
|
public boolean isSubselectFetchingEnabled() {
|
||||||
return loadQueryInfluencers.getSubselectFetchEnabled();
|
return loadQueryInfluencers.getSubselectFetchEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: unused for now, should we promote to Session?
|
@Override
|
||||||
public void setFetchBatchSize(int batchSize) {
|
public void setFetchBatchSize(int batchSize) {
|
||||||
loadQueryInfluencers.setBatchSize( batchSize );
|
loadQueryInfluencers.setBatchSize( batchSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getFetchBatchSize() {
|
public int getFetchBatchSize() {
|
||||||
return loadQueryInfluencers.getBatchSize();
|
return loadQueryInfluencers.getBatchSize();
|
||||||
}
|
}
|
||||||
|
@ -2065,7 +2067,9 @@ public class SessionImpl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SharedSessionBuilderImpl extends SessionFactoryImpl.SessionBuilderImpl implements SharedSessionBuilder, SharedSessionCreationOptions {
|
private static class SharedSessionBuilderImpl
|
||||||
|
extends SessionFactoryImpl.SessionBuilderImpl
|
||||||
|
implements SharedSessionBuilder, SharedSessionCreationOptions {
|
||||||
private final SessionImpl session;
|
private final SessionImpl session;
|
||||||
private boolean shareTransactionContext;
|
private boolean shareTransactionContext;
|
||||||
|
|
||||||
|
@ -2156,28 +2160,6 @@ public class SessionImpl
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilderImpl defaultBatchFetchSize(int batchSize) {
|
|
||||||
super.defaultBatchFetchSize( batchSize );
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilderImpl subselectFetchEnabled(boolean enabled) {
|
|
||||||
super.subselectFetchEnabled( enabled );
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilder defaultBatchFetchSize() {
|
|
||||||
return defaultBatchFetchSize( session.getFetchBatchSize() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SharedSessionBuilder subselectFetchEnabled() {
|
|
||||||
return subselectFetchEnabled( session.isSubselectFetchingEnabled() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SharedSessionBuilderImpl autoClose() {
|
public SharedSessionBuilderImpl autoClose() {
|
||||||
autoClose( session.autoClose );
|
autoClose( session.autoClose );
|
||||||
|
|
Loading…
Reference in New Issue