cleanup and javadoc for SessionFactoryOptions

This commit is contained in:
Gavin King 2024-11-16 10:17:27 +01:00
parent 6880f73ae0
commit 80a1b36477
4 changed files with 233 additions and 38 deletions

View File

@ -210,7 +210,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private boolean orderUpdatesEnabled;
private boolean orderInsertsEnabled;
private boolean collectionsInDefaultFetchGroupEnabled = true;
private final boolean UnownedAssociationTransientCheck;
private final boolean unownedAssociationTransientCheck;
private final boolean passProcedureParameterNames;
private final boolean preferJdbcDatetimeTypes;
@ -597,14 +597,14 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
JDBC_TIME_ZONE
);
if ( jdbcTimeZoneValue instanceof TimeZone ) {
this.jdbcTimeZone = (TimeZone) jdbcTimeZoneValue;
if ( jdbcTimeZoneValue instanceof TimeZone timeZone ) {
this.jdbcTimeZone = timeZone;
}
else if ( jdbcTimeZoneValue instanceof ZoneId ) {
this.jdbcTimeZone = TimeZone.getTimeZone( (ZoneId) jdbcTimeZoneValue );
else if ( jdbcTimeZoneValue instanceof ZoneId zoneId ) {
this.jdbcTimeZone = TimeZone.getTimeZone( zoneId );
}
else if ( jdbcTimeZoneValue instanceof String ) {
this.jdbcTimeZone = TimeZone.getTimeZone( ZoneId.of((String) jdbcTimeZoneValue) );
else if ( jdbcTimeZoneValue instanceof String string ) {
this.jdbcTimeZone = TimeZone.getTimeZone( ZoneId.of( string ) );
}
else if ( jdbcTimeZoneValue != null ) {
throw new IllegalArgumentException( "Configuration property " + JDBC_TIME_ZONE
@ -665,7 +665,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
Statistics.DEFAULT_QUERY_STATISTICS_MAX_SIZE
);
this.UnownedAssociationTransientCheck = getBoolean(
this.unownedAssociationTransientCheck = getBoolean(
UNOWNED_ASSOCIATION_TRANSIENT_CHECK,
configurationSettings,
isJpaBootstrap()
@ -1305,7 +1305,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
@Override
public boolean isUnownedAssociationTransientCheck() {
return UnownedAssociationTransientCheck;
return unownedAssociationTransientCheck;
}
@Override

View File

@ -11,6 +11,7 @@ import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.EntityNameResolver;
import org.hibernate.Incubating;
import org.hibernate.Interceptor;
import org.hibernate.Internal;
import org.hibernate.SessionFactoryObserver;
import org.hibernate.TimeZoneStorageStrategy;
import org.hibernate.annotations.CacheLayout;
@ -63,10 +64,21 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
*/
StandardServiceRegistry getServiceRegistry();
/**
* @see org.hibernate.cfg.ManagedBeanSettings#JAKARTA_CDI_BEAN_MANAGER
*/
Object getBeanManagerReference();
/**
* @see org.hibernate.cfg.ValidationSettings#JAKARTA_VALIDATION_FACTORY
*/
Object getValidatorFactoryReference();
/**
* @see org.hibernate.cfg.JpaComplianceSettings
*/
JpaCompliance getJpaCompliance();
/**
* Was building of the SessionFactory initiated through JPA bootstrapping, or
* through Hibernate's native bootstrapping?
@ -76,8 +88,6 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
*/
boolean isJpaBootstrap();
boolean isJtaTransactionAccessEnabled();
/**
* @deprecated with no replacement.
*/
@ -93,28 +103,33 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
* May also be used as a JNDI name depending on {@value org.hibernate.cfg.PersistenceSettings#SESSION_FACTORY_JNDI_NAME}
* and {@value org.hibernate.cfg.PersistenceSettings#SESSION_FACTORY_NAME_IS_JNDI}.
*
* @return The SessionFactory name
* @return The session factory name
*
* @see org.hibernate.cfg.PersistenceSettings#SESSION_FACTORY_NAME
*/
String getSessionFactoryName();
/**
* Is the {@link #getSessionFactoryName SesssionFactory name} also a JNDI name, indicating we
* Is the {@linkplain #getSessionFactoryName session factory name} also a JNDI name, indicating we
* should bind it into JNDI?
*
* @return {@code true} if the SessionFactory name is also a JNDI name; {@code false} otherwise.
*
* @see org.hibernate.cfg.PersistenceSettings#SESSION_FACTORY_NAME_IS_JNDI
*/
Boolean isSessionFactoryNameAlsoJndiName();
boolean isFlushBeforeCompletionEnabled();
boolean isAutoCloseSessionEnabled();
/**
* @see org.hibernate.cfg.StatisticsSettings#GENERATE_STATISTICS
*/
boolean isStatisticsEnabled();
/**
* Get the interceptor to use by default for all sessions opened from this factory.
*
* @return The interceptor to use factory wide. May be {@code null}
*
* @see org.hibernate.cfg.SessionEventSettings#INTERCEPTOR
*/
Interceptor getInterceptor();
@ -122,11 +137,19 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
* Get the interceptor to use by default for all sessions opened from this factory.
*
* @return The interceptor to use factory wide. May be {@code null}
*
* @see org.hibernate.cfg.SessionEventSettings#SESSION_SCOPED_INTERCEPTOR
*/
Supplier<? extends Interceptor> getStatelessInterceptorImplementorSupplier();
/**
* @see org.hibernate.cfg.JdbcSettings#STATEMENT_INSPECTOR
*/
StatementInspector getStatementInspector();
/**
* @see org.hibernate.cfg.AvailableSettings#SESSION_FACTORY_OBSERVER
*/
SessionFactoryObserver[] getSessionFactoryObservers();
BaselineSessionEventsListenerBuilder getBaselineSessionEventsListenerBuilder();
@ -138,92 +161,214 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
*/
boolean isIdentifierRollbackEnabled();
/**
* @see org.hibernate.cfg.ValidationSettings#CHECK_NULLABILITY
*/
boolean isCheckNullability();
/**
* Allows use of Bean Validation to disable null checking.
*/
@Internal
void setCheckNullability(boolean enabled);
/**
* @see org.hibernate.cfg.AvailableSettings#ENABLE_LAZY_LOAD_NO_TRANS
*/
boolean isInitializeLazyStateOutsideTransactionsEnabled();
TempTableDdlTransactionHandling getTempTableDdlTransactionHandling();
/**
* @see org.hibernate.cfg.AvailableSettings#DELAY_ENTITY_LOADER_CREATIONS
*/
boolean isDelayBatchFetchLoaderCreationsEnabled();
/**
* @see org.hibernate.cfg.FetchSettings#DEFAULT_BATCH_FETCH_SIZE
*/
int getDefaultBatchFetchSize();
/**
* @see org.hibernate.cfg.FetchSettings#MAX_FETCH_DEPTH
*/
Integer getMaximumFetchDepth();
/**
* @see org.hibernate.cfg.FetchSettings#USE_SUBSELECT_FETCH
*/
boolean isSubselectFetchEnabled();
/**
* @see org.hibernate.cfg.QuerySettings#DEFAULT_NULL_ORDERING
*/
Nulls getDefaultNullPrecedence();
/**
* @see org.hibernate.cfg.BatchSettings#ORDER_UPDATES
*/
boolean isOrderUpdatesEnabled();
/**
* @see org.hibernate.cfg.BatchSettings#ORDER_INSERTS
*/
boolean isOrderInsertsEnabled();
/**
* @see org.hibernate.cfg.MultiTenancySettings#MULTI_TENANT_CONNECTION_PROVIDER
*/
boolean isMultiTenancyEnabled();
/**
* @see org.hibernate.cfg.MultiTenancySettings#MULTI_TENANT_IDENTIFIER_RESOLVER
*/
CurrentTenantIdentifierResolver<Object> getCurrentTenantIdentifierResolver();
boolean isJtaTrackByThread();
/**
* @see org.hibernate.cfg.QuerySettings#QUERY_STARTUP_CHECKING
*/
boolean isNamedQueryStartupCheckingEnabled();
/**
* @see org.hibernate.cfg.CacheSettings#USE_SECOND_LEVEL_CACHE
*/
boolean isSecondLevelCacheEnabled();
/**
* @see org.hibernate.cfg.CacheSettings#USE_QUERY_CACHE
*/
boolean isQueryCacheEnabled();
/**
* @see org.hibernate.cfg.CacheSettings#QUERY_CACHE_LAYOUT
*/
@Incubating
CacheLayout getQueryCacheLayout();
/**
* @see org.hibernate.cfg.CacheSettings#QUERY_CACHE_FACTORY
*/
TimestampsCacheFactory getTimestampsCacheFactory();
/**
* @see org.hibernate.cfg.CacheSettings#CACHE_REGION_PREFIX
*/
String getCacheRegionPrefix();
/**
* @see org.hibernate.cfg.CacheSettings#USE_MINIMAL_PUTS
*/
boolean isMinimalPutsEnabled();
/**
* @see org.hibernate.cfg.CacheSettings#USE_STRUCTURED_CACHE
*/
boolean isStructuredCacheEntriesEnabled();
/**
* @see org.hibernate.cfg.CacheSettings#USE_DIRECT_REFERENCE_CACHE_ENTRIES
*/
boolean isDirectReferenceCacheEntriesEnabled();
/**
* @see org.hibernate.cfg.CacheSettings#AUTO_EVICT_COLLECTION_CACHE
*/
boolean isAutoEvictCollectionCache();
SchemaAutoTooling getSchemaAutoTooling();
/**
* @see org.hibernate.cfg.BatchSettings#STATEMENT_BATCH_SIZE
*/
int getJdbcBatchSize();
/**
* @see org.hibernate.cfg.BatchSettings#BATCH_VERSIONED_DATA
*/
boolean isJdbcBatchVersionedData();
/**
* @see org.hibernate.cfg.JdbcSettings#USE_SCROLLABLE_RESULTSET
*/
boolean isScrollableResultSetsEnabled();
/**
* @see org.hibernate.cfg.JdbcSettings#USE_GET_GENERATED_KEYS
*/
boolean isGetGeneratedKeysEnabled();
/**
* @see org.hibernate.cfg.JdbcSettings#STATEMENT_FETCH_SIZE
*/
Integer getJdbcFetchSize();
/**
* @see org.hibernate.cfg.JdbcSettings#CONNECTION_HANDLING
*/
PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode();
default boolean doesConnectionProviderDisableAutoCommit() {
return false;
}
/**
* @see org.hibernate.cfg.JdbcSettings#CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT
*/
boolean doesConnectionProviderDisableAutoCommit();
/**
* @see org.hibernate.cfg.JdbcSettings#USE_SQL_COMMENTS
*/
boolean isCommentsEnabled();
/**
* @see org.hibernate.cfg.AvailableSettings#CUSTOM_ENTITY_DIRTINESS_STRATEGY
*/
CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy();
EntityNameResolver[] getEntityNameResolvers();
/**
* Get the delegate for handling entity-not-found exception conditions.
* <p>
* Returns {@link org.hibernate.boot.internal.StandardEntityNotFoundDelegate}
* by default.
*
* @return The specific EntityNotFoundDelegate to use, May be {@code null}
* @return The specific {@link EntityNotFoundDelegate} to use, May be {@code null}
*/
EntityNotFoundDelegate getEntityNotFoundDelegate();
void setCheckNullability(boolean enabled);
/**
* @see org.hibernate.cfg.TransactionSettings#FLUSH_BEFORE_COMPLETION
*/
boolean isFlushBeforeCompletionEnabled();
/**
* @see org.hibernate.cfg.TransactionSettings#AUTO_CLOSE_SESSION
*/
boolean isAutoCloseSessionEnabled();
/**
* @see org.hibernate.cfg.TransactionSettings#ALLOW_JTA_TRANSACTION_ACCESS
*/
boolean isJtaTransactionAccessEnabled();
/**
* @see org.hibernate.cfg.TransactionSettings#PREFER_USER_TRANSACTION
*/
boolean isPreferUserTransaction();
/**
* @see org.hibernate.cfg.TransactionSettings#ALLOW_UPDATE_OUTSIDE_TRANSACTION
*/
boolean isAllowOutOfTransactionUpdateOperations();
/**
* @see org.hibernate.cfg.AvailableSettings#DISCARD_PC_ON_CLOSE
*/
boolean isReleaseResourcesOnCloseEnabled();
/**
* @see org.hibernate.cfg.JdbcSettings#JDBC_TIME_ZONE
*/
TimeZone getJdbcTimeZone();
/**
@ -247,8 +392,9 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
return false;
}
JpaCompliance getJpaCompliance();
/**
* @see org.hibernate.cfg.QuerySettings#FAIL_ON_PAGINATION_OVER_COLLECTION_FETCH
*/
boolean isFailOnPaginationOverCollectionFetchEnabled();
/**
@ -306,13 +452,15 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
return false;
}
default int getQueryStatisticsMaxSize() {
return Statistics.DEFAULT_QUERY_STATISTICS_MAX_SIZE;
}
/**
* @see org.hibernate.cfg.StatisticsSettings#QUERY_STATISTICS_MAX_SIZE
*/
int getQueryStatisticsMaxSize();
default boolean areJPACallbacksEnabled() {
return true;
}
/**
* @see org.hibernate.cfg.PersistenceSettings#JPA_CALLBACKS_ENABLED
*/
boolean areJPACallbacksEnabled();
/**
* Controls whether Hibernate should try to map named parameter names
@ -344,33 +492,62 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
return false;
}
/**
* @see org.hibernate.cfg.PersistenceSettings#UNOWNED_ASSOCIATION_TRANSIENT_CHECK
*/
boolean isUnownedAssociationTransientCheck();
/**
* @see org.hibernate.cfg.MappingSettings#PREFERRED_BOOLEAN_JDBC_TYPE
*/
@Incubating
int getPreferredSqlTypeCodeForBoolean();
/**
* @see org.hibernate.cfg.MappingSettings#PREFERRED_DURATION_JDBC_TYPE
*/
@Incubating
int getPreferredSqlTypeCodeForDuration();
/**
* @see org.hibernate.cfg.MappingSettings#PREFERRED_UUID_JDBC_TYPE
*/
@Incubating
int getPreferredSqlTypeCodeForUuid();
/**
* @see org.hibernate.cfg.MappingSettings#PREFERRED_INSTANT_JDBC_TYPE
*/
@Incubating
int getPreferredSqlTypeCodeForInstant();
/**
* @see org.hibernate.cfg.MappingSettings#PREFERRED_ARRAY_JDBC_TYPE
*/
@Incubating
int getPreferredSqlTypeCodeForArray();
/**
* @see org.hibernate.cfg.MappingSettings#TIMEZONE_DEFAULT_STORAGE
*/
@Incubating
TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy();
/**
* @see org.hibernate.cfg.MappingSettings#JAVA_TIME_USE_DIRECT_JDBC
*/
boolean isPreferJavaTimeJdbcTypesEnabled();
/**
* @see org.hibernate.cfg.MappingSettings#PREFER_NATIVE_ENUM_TYPES
*/
boolean isPreferNativeEnumTypesEnabled();
/**
* The format mapper to use for serializing/deserializing JSON data.
*
* @see org.hibernate.cfg.MappingSettings#JSON_FORMAT_MAPPER
*
* @since 6.0
*/
@Incubating
@ -379,6 +556,8 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
/**
* The format mapper to use for serializing/deserializing XML data.
*
* @see org.hibernate.cfg.MappingSettings#XML_FORMAT_MAPPER
*
* @since 6.0.1
*/
@Incubating
@ -394,6 +573,9 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
return ObjectJavaType.INSTANCE;
}
/**
* @see org.hibernate.cfg.QuerySettings#QUERY_PASS_PROCEDURE_PARAMETER_NAMES
*/
boolean isPassProcedureParameterNames();
/**

View File

@ -245,16 +245,24 @@ public interface MappingSettings {
String JAVA_TIME_USE_DIRECT_JDBC = "hibernate.type.java_time_use_direct_jdbc";
/**
* Indicates whether to prefer using SQL enums and the respective special JDBC types for binding/extracting
* of values.
* <p/>
* Used to set the value across the entire system as opposed to scattered, individual
* {@linkplain org.hibernate.annotations.JdbcTypeCode} and {@linkplain org.hibernate.annotations.JdbcType}
* naming specific {@linkplain org.hibernate.type.descriptor.jdbc.JdbcType} implementations.
* Indicates that named SQL {@code enum} types should be used by default instead
* of {@code varchar} on databases which support named enum types.
* <p>
* A named enum type is declared in DDL using {@code create type ... as enum} or
* {@code create type ... as domain}.
* <p>
* This configuration property is used to specify a global preference, as an
* alternative to the use of
* {@link org.hibernate.annotations.JdbcTypeCode @JdbcTypeCode(SqlTypes.NAMED_ENUM)}
* at the field or property level.
*
* @settingDefault false
*
* @since 6.5
*
* @see org.hibernate.type.SqlTypes#NAMED_ENUM
* @see org.hibernate.dialect.PostgreSQLEnumJdbcType
* @see org.hibernate.dialect.OracleEnumJdbcType
*/
@Incubating
String PREFER_NATIVE_ENUM_TYPES = "hibernate.type.prefer_native_enum_types";

View File

@ -643,10 +643,15 @@ public class SqlTypes {
/**
* A type code representing a SQL {@code ENUM} type for databases like
* {@link org.hibernate.dialect.PostgreSQLDialect PostgreSQL} where
* {@link org.hibernate.dialect.PostgreSQLDialect PostgreSQL} or
* {@link org.hibernate.dialect.OracleDialect Oracle} where
* {@code ENUM} types must have names.
* <p>
* A named enum type is declared in DDL using {@code create type ... as enum}
* or {@code create type ... as domain}.
*
* @see org.hibernate.dialect.PostgreSQLEnumJdbcType
* @see org.hibernate.dialect.OracleEnumJdbcType
*
* @since 6.3
*/