|
59 | 59 | import org.hibernate.dialect.Dialect;
|
60 | 60 | import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
|
61 | 61 | import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
62 |
| -import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess; |
63 | 62 | import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
|
64 | 63 | import org.hibernate.engine.jdbc.spi.JdbcServices;
|
65 | 64 | import org.hibernate.engine.profile.FetchProfile;
|
@@ -453,13 +452,8 @@ private void disintegrate(Exception startupException, IntegratorObserver integra
|
453 | 452 |
|
454 | 453 | private SessionBuilderImpl createDefaultSessionOpenOptionsIfPossible() {
|
455 | 454 | 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; |
463 | 457 | }
|
464 | 458 |
|
465 | 459 | private SessionBuilderImpl buildTemporarySessionOpenOptions() {
|
@@ -817,16 +811,16 @@ public void close() {
|
817 | 811 | }
|
818 | 812 |
|
819 | 813 | if ( runtimeMetamodels != null && runtimeMetamodels.getMappingMetamodel() != null ) {
|
820 |
| - final JdbcConnectionAccess jdbcConnectionAccess = jdbcServices.getBootstrapJdbcConnectionAccess(); |
| 814 | + final var jdbcConnectionAccess = jdbcServices.getBootstrapJdbcConnectionAccess(); |
821 | 815 | runtimeMetamodels.getMappingMetamodel().forEachEntityDescriptor(
|
822 | 816 | 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 ); |
826 | 821 | }
|
827 |
| - if ( entityPersister.getSqmMultiTableInsertStrategy() != null ) { |
828 |
| - entityPersister.getSqmMultiTableInsertStrategy() |
829 |
| - .release( this, jdbcConnectionAccess ); |
| 822 | + if ( insertStrategy != null ) { |
| 823 | + insertStrategy.release( this, jdbcConnectionAccess ); |
830 | 824 | }
|
831 | 825 | }
|
832 | 826 | );
|
@@ -960,7 +954,7 @@ public StatisticsImplementor getStatistics() {
|
960 | 954 | }
|
961 | 955 |
|
962 | 956 | public FilterDefinition getFilterDefinition(String filterName) {
|
963 |
| - final FilterDefinition filterDefinition = filters.get( filterName ); |
| 957 | + final var filterDefinition = filters.get( filterName ); |
964 | 958 | if ( filterDefinition == null ) {
|
965 | 959 | throw new UnknownFilterException( filterName );
|
966 | 960 | }
|
@@ -1088,7 +1082,7 @@ public static Interceptor configuredInterceptor(Interceptor interceptor, boolean
|
1088 | 1082 | }
|
1089 | 1083 |
|
1090 | 1084 | // 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(); |
1092 | 1086 | if ( optionsInterceptor != null && optionsInterceptor != EmptyInterceptor.INSTANCE ) {
|
1093 | 1087 | return optionsInterceptor;
|
1094 | 1088 | }
|
@@ -1140,20 +1134,20 @@ public SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
|
1140 | 1134 | this.sessionFactory = sessionFactory;
|
1141 | 1135 |
|
1142 | 1136 | // set up default builder values...
|
1143 |
| - final SessionFactoryOptions sessionFactoryOptions = 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 var options = 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(); |
1150 | 1144 |
|
1151 | 1145 | final var currentTenantIdentifierResolver =
|
1152 | 1146 | sessionFactory.getCurrentTenantIdentifierResolver();
|
1153 | 1147 | if ( currentTenantIdentifierResolver != null ) {
|
1154 | 1148 | tenantIdentifier = currentTenantIdentifierResolver.resolveCurrentTenantIdentifier();
|
1155 | 1149 | }
|
1156 |
| - jdbcTimeZone = sessionFactoryOptions.getJdbcTimeZone(); |
| 1150 | + jdbcTimeZone = options.getJdbcTimeZone(); |
1157 | 1151 | }
|
1158 | 1152 |
|
1159 | 1153 |
|
@@ -1219,10 +1213,9 @@ public PhysicalConnectionHandlingMode getPhysicalConnectionHandlingMode() {
|
1219 | 1213 |
|
1220 | 1214 | @Override
|
1221 | 1215 | 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; |
1226 | 1219 | }
|
1227 | 1220 |
|
1228 | 1221 | @Override
|
|
0 commit comments