Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0d58851

Browse files
minor cleanups to SessionFactoryImpl
1 parent 675105f commit 0d58851

File tree

2 files changed

+43
-36
lines changed

2 files changed

+43
-36
lines changed

‎hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import org.hibernate.dialect.Dialect;
6060
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
6161
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
62-
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
6362
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
6463
import org.hibernate.engine.jdbc.spi.JdbcServices;
6564
import org.hibernate.engine.profile.FetchProfile;
@@ -453,13 +452,8 @@ private void disintegrate(Exception startupException, IntegratorObserver integra
453452

454453
private SessionBuilderImpl createDefaultSessionOpenOptionsIfPossible() {
455454
final var tenantIdResolver = getCurrentTenantIdentifierResolver();
456-
if ( tenantIdResolver == null ) {
457-
return withOptions();
458-
}
459-
else {
460-
//Don't store a default SessionBuilder when a CurrentTenantIdentifierResolver is provided
461-
return null;
462-
}
455+
// Don't store a default SessionBuilder when a CurrentTenantIdentifierResolver is provided
456+
return tenantIdResolver == null ? withOptions() : null;
463457
}
464458

465459
private SessionBuilderImpl buildTemporarySessionOpenOptions() {
@@ -817,16 +811,16 @@ public void close() {
817811
}
818812

819813
if ( runtimeMetamodels != null && runtimeMetamodels.getMappingMetamodel() != null ) {
820-
final JdbcConnectionAccess jdbcConnectionAccess = jdbcServices.getBootstrapJdbcConnectionAccess();
814+
final var jdbcConnectionAccess = jdbcServices.getBootstrapJdbcConnectionAccess();
821815
runtimeMetamodels.getMappingMetamodel().forEachEntityDescriptor(
822816
entityPersister -> {
823-
if ( entityPersister.getSqmMultiTableMutationStrategy() != null ) {
824-
entityPersister.getSqmMultiTableMutationStrategy()
825-
.release( this, jdbcConnectionAccess );
817+
final var mutationStrategy = entityPersister.getSqmMultiTableMutationStrategy();
818+
final var insertStrategy = entityPersister.getSqmMultiTableInsertStrategy();
819+
if ( mutationStrategy != null ) {
820+
mutationStrategy.release( this, jdbcConnectionAccess );
826821
}
827-
if ( entityPersister.getSqmMultiTableInsertStrategy() != null ) {
828-
entityPersister.getSqmMultiTableInsertStrategy()
829-
.release( this, jdbcConnectionAccess );
822+
if ( insertStrategy != null ) {
823+
insertStrategy.release( this, jdbcConnectionAccess );
830824
}
831825
}
832826
);
@@ -960,7 +954,7 @@ public StatisticsImplementor getStatistics() {
960954
}
961955

962956
public FilterDefinition getFilterDefinition(String filterName) {
963-
final FilterDefinition filterDefinition = filters.get( filterName );
957+
final var filterDefinition = filters.get( filterName );
964958
if ( filterDefinition == null ) {
965959
throw new UnknownFilterException( filterName );
966960
}
@@ -1088,7 +1082,7 @@ public static Interceptor configuredInterceptor(Interceptor interceptor, boolean
10881082
}
10891083

10901084
// prefer the SessionFactory-scoped interceptor, prefer that to any Session-scoped interceptor prototype
1091-
final Interceptor optionsInterceptor = options.getInterceptor();
1085+
final var optionsInterceptor = options.getInterceptor();
10921086
if ( optionsInterceptor != null && optionsInterceptor != EmptyInterceptor.INSTANCE ) {
10931087
return optionsInterceptor;
10941088
}
@@ -1140,20 +1134,20 @@ public SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
11401134
this.sessionFactory = sessionFactory;
11411135

11421136
// set up default builder values...
1143-
final SessionFactoryOptionssessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
1144-
statementInspector = sessionFactoryOptions.getStatementInspector();
1145-
connectionHandlingMode = sessionFactoryOptions.getPhysicalConnectionHandlingMode();
1146-
autoClose = sessionFactoryOptions.isAutoCloseSessionEnabled();
1147-
defaultBatchFetchSize = sessionFactoryOptions.getDefaultBatchFetchSize();
1148-
subselectFetchEnabled = sessionFactoryOptions.isSubselectFetchEnabled();
1149-
identifierRollback = sessionFactoryOptions.isIdentifierRollbackEnabled();
1137+
final varoptions = sessionFactory.getSessionFactoryOptions();
1138+
statementInspector = options.getStatementInspector();
1139+
connectionHandlingMode = options.getPhysicalConnectionHandlingMode();
1140+
autoClose = options.isAutoCloseSessionEnabled();
1141+
defaultBatchFetchSize = options.getDefaultBatchFetchSize();
1142+
subselectFetchEnabled = options.isSubselectFetchEnabled();
1143+
identifierRollback = options.isIdentifierRollbackEnabled();
11501144

11511145
final var currentTenantIdentifierResolver =
11521146
sessionFactory.getCurrentTenantIdentifierResolver();
11531147
if ( currentTenantIdentifierResolver != null ) {
11541148
tenantIdentifier = currentTenantIdentifierResolver.resolveCurrentTenantIdentifier();
11551149
}
1156-
jdbcTimeZone = sessionFactoryOptions.getJdbcTimeZone();
1150+
jdbcTimeZone = options.getJdbcTimeZone();
11571151
}
11581152

11591153

@@ -1219,10 +1213,9 @@ public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() {
12191213

12201214
@Override
12211215
public String getTenantIdentifier() {
1222-
if ( tenantIdentifier == null ) {
1223-
return null;
1224-
}
1225-
return sessionFactory.getTenantIdentifierJavaType().toString( tenantIdentifier );
1216+
return tenantIdentifier != null
1217+
? sessionFactory.getTenantIdentifierJavaType().toString( tenantIdentifier )
1218+
: null;
12261219
}
12271220

12281221
@Override

‎hibernate-core/src/main/java/org/hibernate/internal/SessionFactorySettings.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,33 @@ static void deprecationCheck(Map<String, Object> settings) {
116116
for ( String setting:settings.keySet() ) {
117117
switch ( setting ) {
118118
case "hibernate.hql.bulk_id_strategy.global_temporary.create_tables":
119-
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.global_temporary.create_tables", GlobalTemporaryTableStrategy.CREATE_ID_TABLES );
119+
DEPRECATION_LOGGER.deprecatedSetting(
120+
"hibernate.hql.bulk_id_strategy.global_temporary.create_tables",
121+
GlobalTemporaryTableStrategy.CREATE_ID_TABLES );
120122
case "hibernate.hql.bulk_id_strategy.global_temporary.drop_tables":
121-
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.global_temporary.drop_tables", GlobalTemporaryTableStrategy.DROP_ID_TABLES );
123+
DEPRECATION_LOGGER.deprecatedSetting(
124+
"hibernate.hql.bulk_id_strategy.global_temporary.drop_tables",
125+
GlobalTemporaryTableStrategy.DROP_ID_TABLES );
122126
case "hibernate.hql.bulk_id_strategy.persistent.create_tables":
123-
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.create_tables", PersistentTableStrategy.CREATE_ID_TABLES );
127+
DEPRECATION_LOGGER.deprecatedSetting(
128+
"hibernate.hql.bulk_id_strategy.persistent.create_tables",
129+
PersistentTableStrategy.CREATE_ID_TABLES );
124130
case "hibernate.hql.bulk_id_strategy.persistent.drop_tables":
125-
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.drop_tables", PersistentTableStrategy.DROP_ID_TABLES );
131+
DEPRECATION_LOGGER.deprecatedSetting(
132+
"hibernate.hql.bulk_id_strategy.persistent.drop_tables",
133+
PersistentTableStrategy.DROP_ID_TABLES );
126134
case "hibernate.hql.bulk_id_strategy.persistent.schema":
127-
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.schema", PersistentTableStrategy.SCHEMA );
135+
DEPRECATION_LOGGER.deprecatedSetting(
136+
"hibernate.hql.bulk_id_strategy.persistent.schema",
137+
PersistentTableStrategy.SCHEMA );
128138
case "hibernate.hql.bulk_id_strategy.persistent.catalog":
129-
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.catalog", PersistentTableStrategy.CATALOG );
139+
DEPRECATION_LOGGER.deprecatedSetting(
140+
"hibernate.hql.bulk_id_strategy.persistent.catalog",
141+
PersistentTableStrategy.CATALOG );
130142
case "hibernate.hql.bulk_id_strategy.local_temporary.drop_tables":
131-
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.local_temporary.drop_tables", LocalTemporaryTableStrategy.DROP_ID_TABLES );
143+
DEPRECATION_LOGGER.deprecatedSetting(
144+
"hibernate.hql.bulk_id_strategy.local_temporary.drop_tables",
145+
LocalTemporaryTableStrategy.DROP_ID_TABLES );
132146
}
133147
}
134148
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /