20
20
import java .util .concurrent .ConcurrentHashMap ;
21
21
import java .util .function .Consumer ;
22
22
import java .util .function .Function ;
23
- import java .util .function .Supplier ;
24
23
import java .util .function .UnaryOperator ;
25
24
import javax .naming .Reference ;
26
25
import javax .naming .StringRefAddr ;
83
82
import org .hibernate .integrator .spi .IntegratorService ;
84
83
import org .hibernate .jpa .internal .ExceptionMapperLegacyJpaImpl ;
85
84
import org .hibernate .jpa .internal .PersistenceUnitUtilImpl ;
86
- import org .hibernate .mapping .Collection ;
87
85
import org .hibernate .mapping .GeneratorSettings ;
88
- import org .hibernate .mapping .PersistentClass ;
89
86
import org .hibernate .mapping .RootClass ;
90
87
import org .hibernate .metamodel .MappingMetamodel ;
91
88
import org .hibernate .metamodel .RepresentationMode ;
92
89
import org .hibernate .metamodel .internal .RuntimeMetamodelsImpl ;
93
- import org .hibernate .metamodel .mapping .JdbcMapping ;
94
90
import org .hibernate .metamodel .model .domain .EntityDomainType ;
95
91
import org .hibernate .metamodel .model .domain .internal .MappingMetamodelImpl ;
96
92
import org .hibernate .metamodel .model .domain .spi .JpaMetamodelImplementor ;
@@ -254,23 +250,23 @@ public SessionFactoryImpl(
254
250
255
251
jpaPersistenceUnitUtil = new PersistenceUnitUtilImpl ( this );
256
252
257
- for ( SessionFactoryObserver sessionFactoryObserver : options .getSessionFactoryObservers () ) {
253
+ for ( var sessionFactoryObserver : options .getSessionFactoryObservers () ) {
258
254
observer .addObserver ( sessionFactoryObserver );
259
255
}
260
256
261
257
filters = new HashMap <>( bootMetamodel .getFilterDefinitions () );
262
258
263
- final FilterDefinition tenantFilter = filters .get ( TenantIdBinder .FILTER_NAME );
259
+ final var tenantFilter = filters .get ( TenantIdBinder .FILTER_NAME );
264
260
if ( tenantFilter == null ) {
265
261
tenantIdentifierJavaType = options .getDefaultTenantIdentifierJavaType ();
266
262
}
267
263
else {
268
- final JdbcMapping jdbcMapping = tenantFilter .getParameterJdbcMapping ( TenantIdBinder .PARAMETER_NAME );
264
+ final var jdbcMapping = tenantFilter .getParameterJdbcMapping ( TenantIdBinder .PARAMETER_NAME );
269
265
assert jdbcMapping != null ;
270
266
//noinspection unchecked
271
267
tenantIdentifierJavaType = jdbcMapping .getJavaTypeDescriptor ();
272
268
}
273
- for ( Map . Entry < String , FilterDefinition > filterEntry : filters .entrySet () ) {
269
+ for ( var filterEntry : filters .entrySet () ) {
274
270
if ( filterEntry .getValue ().isAutoEnabled () ) {
275
271
autoEnabledFilters .add ( filterEntry .getValue () );
276
272
}
@@ -283,7 +279,7 @@ public SessionFactoryImpl(
283
279
classLoaderService = serviceRegistry .requireService ( ClassLoaderService .class );
284
280
jdbcValuesMappingProducerProvider = serviceRegistry .requireService ( JdbcValuesMappingProducerProvider .class );
285
281
286
- final IntegratorObserver integratorObserver = new IntegratorObserver ();
282
+ final var integratorObserver = new IntegratorObserver ();
287
283
observer .addObserver ( integratorObserver );
288
284
try {
289
285
integrate ( bootMetamodel , bootstrapContext , integratorObserver );
@@ -294,7 +290,7 @@ public SessionFactoryImpl(
294
290
primeSecondLevelCacheRegions ( bootMetamodel );
295
291
296
292
// create the empty runtime metamodels object
297
- final RuntimeMetamodelsImpl runtimeMetamodelsImpl = new RuntimeMetamodelsImpl ( typeConfiguration );
293
+ final var runtimeMetamodelsImpl = new RuntimeMetamodelsImpl ( typeConfiguration );
298
294
runtimeMetamodels = runtimeMetamodelsImpl ;
299
295
300
296
// we build this before creating the runtime metamodels
@@ -305,7 +301,7 @@ public SessionFactoryImpl(
305
301
sqlTranslationEngine = new SqlTranslationEngineImpl ( this , typeConfiguration , fetchProfiles );
306
302
307
303
// now actually create the mapping and JPA metamodels
308
- final MappingMetamodelImpl mappingMetamodelImpl = new MappingMetamodelImpl ( typeConfiguration , serviceRegistry );
304
+ final var mappingMetamodelImpl = new MappingMetamodelImpl ( typeConfiguration , serviceRegistry );
309
305
runtimeMetamodelsImpl .setMappingMetamodel ( mappingMetamodelImpl );
310
306
mappingMetamodelImpl .finishInitialization (
311
307
new ModelCreationContext ( bootstrapContext , bootMetamodel , mappingMetamodelImpl , typeConfiguration ) );
@@ -432,22 +428,22 @@ class IntegratorObserver implements SessionFactoryObserver {
432
428
private final ArrayList <Integrator > integrators = new ArrayList <>();
433
429
@ Override
434
430
public void sessionFactoryClosed (SessionFactory factory ) {
435
- for ( Integrator integrator : integrators ) {
431
+ for ( var integrator : integrators ) {
436
432
integrator .disintegrate ( SessionFactoryImpl .this , SessionFactoryImpl .this .serviceRegistry );
437
433
}
438
434
integrators .clear ();
439
435
}
440
436
}
441
437
442
438
private void integrate (MetadataImplementor bootMetamodel , BootstrapContext bootstrapContext , IntegratorObserver integratorObserver ) {
443
- for ( Integrator integrator : serviceRegistry .requireService ( IntegratorService .class ).getIntegrators () ) {
439
+ for ( var integrator : serviceRegistry .requireService ( IntegratorService .class ).getIntegrators () ) {
444
440
integrator .integrate ( bootMetamodel , bootstrapContext , this );
445
441
integratorObserver .integrators .add ( integrator );
446
442
}
447
443
}
448
444
449
445
private void disintegrate (Exception startupException , IntegratorObserver integratorObserver ) {
450
- for ( Integrator integrator : integratorObserver .integrators ) {
446
+ for ( var integrator : integratorObserver .integrators ) {
451
447
try {
452
448
integrator .disintegrate ( this , serviceRegistry );
453
449
}
@@ -483,10 +479,9 @@ private void primeSecondLevelCacheRegions(MetadataImplementor mappingMetadata) {
483
479
// TODO: ultimately this code can be made more efficient when we have
484
480
// a better intrinsic understanding of the hierarchy as a whole
485
481
486
- for ( PersistentClass bootEntityDescriptor : mappingMetadata .getEntityBindings () ) {
482
+ for ( var bootEntityDescriptor : mappingMetadata .getEntityBindings () ) {
487
483
final AccessType accessType =
488
484
AccessType .fromExternalName ( bootEntityDescriptor .getCacheConcurrencyStrategy () );
489
-
490
485
if ( accessType != null ) {
491
486
if ( bootEntityDescriptor .isCached () ) {
492
487
regionConfigBuilders .computeIfAbsent (
@@ -508,8 +503,9 @@ private void primeSecondLevelCacheRegions(MetadataImplementor mappingMetadata) {
508
503
}
509
504
}
510
505
511
- for ( Collection collection : mappingMetadata .getCollectionBindings () ) {
512
- final AccessType accessType = AccessType .fromExternalName ( collection .getCacheConcurrencyStrategy () );
506
+ for ( var collection : mappingMetadata .getCollectionBindings () ) {
507
+ final AccessType accessType =
508
+ AccessType .fromExternalName ( collection .getCacheConcurrencyStrategy () );
513
509
if ( accessType != null ) {
514
510
regionConfigBuilders .computeIfAbsent (
515
511
collection .getCacheRegionName (),
@@ -525,7 +521,7 @@ private void primeSecondLevelCacheRegions(MetadataImplementor mappingMetadata) {
525
521
}
526
522
else {
527
523
regionConfigs = new HashSet <>();
528
- for ( DomainDataRegionConfigImpl . Builder builder : regionConfigBuilders .values () ) {
524
+ for ( var builder : regionConfigBuilders .values () ) {
529
525
regionConfigs .add ( builder .build () );
530
526
}
531
527
}
@@ -735,12 +731,12 @@ public boolean isOpen() {
735
731
736
732
@ Override
737
733
public RootGraph <Map <String , ?>> createGraphForDynamicEntity (String entityName ) {
738
- final EntityDomainType <?> entity = getJpaMetamodel ().entity ( entityName );
734
+ final var entity = getJpaMetamodel ().entity ( entityName );
739
735
if ( entity .getRepresentationMode () != RepresentationMode .MAP ) {
740
736
throw new IllegalArgumentException ( "Entity '" + entityName + "' is not a dynamic entity" );
741
737
}
742
738
@ SuppressWarnings ("unchecked" ) //Safe, because we just checked
743
- final EntityDomainType < Map < String , ?>> dynamicEntity = (EntityDomainType <Map <String , ?>>) entity ;
739
+ final var dynamicEntity = (EntityDomainType <Map <String , ?>>) entity ;
744
740
return new RootGraphImpl <>( null , dynamicEntity );
745
741
}
746
742
@@ -1108,7 +1104,7 @@ public static Interceptor configuredInterceptor(Interceptor interceptor, boolean
1108
1104
}
1109
1105
1110
1106
// then check the Session-scoped interceptor prototype
1111
- final Supplier <? extends Interceptor > statelessInterceptorImplementorSupplier =
1107
+ final var statelessInterceptorImplementorSupplier =
1112
1108
options .getStatelessInterceptorImplementorSupplier ();
1113
1109
if ( statelessInterceptorImplementorSupplier != null ) {
1114
1110
return statelessInterceptorImplementorSupplier .get ();
0 commit comments