3939import org .hibernate .engine .config .spi .ConfigurationService ;
4040import org .hibernate .engine .spi .FilterDefinition ;
4141import org .hibernate .engine .spi .SessionFactoryImplementor ;
42- import org .hibernate .event .service .spi .EventListenerGroup ;
4342import org .hibernate .event .service .spi .EventListenerRegistry ;
4443import org .hibernate .event .spi .EventType ;
4544import org .hibernate .mapping .Collection ;
46- import org .hibernate .mapping .Column ;
4745import org .hibernate .mapping .Component ;
4846import org .hibernate .mapping .FetchProfile ;
49- import org .hibernate .mapping .ForeignKey ;
5047import org .hibernate .mapping .MappedSuperclass ;
5148import org .hibernate .mapping .PersistentClass ;
52- import org .hibernate .mapping .PrimaryKey ;
53- import org .hibernate .mapping .Property ;
5449import org .hibernate .mapping .Table ;
5550import org .hibernate .mapping .UserDefinedObjectType ;
5651import org .hibernate .mapping .UserDefinedType ;
5954import org .hibernate .query .named .NamedObjectRepository ;
6055import org .hibernate .query .sqm .function .SqmFunctionDescriptor ;
6156import org .hibernate .query .sqm .function .SqmFunctionRegistry ;
62- import org .hibernate .service .spi .ServiceRegistryImplementor ;
6357import org .hibernate .tool .schema .Action ;
6458import org .hibernate .tool .schema .spi .SchemaManagementToolCoordinator .ActionGrouping ;
6559import org .hibernate .type .spi .TypeConfiguration ;
@@ -331,28 +325,23 @@ public Map<String, SqmFunctionDescriptor> getSqlFunctionMap() {
331325 @ Override
332326 public Set <String > getContributors () {
333327 final HashSet <String > contributors = new HashSet <>();
334-
335- entityBindingMap .forEach (
336- (s , persistentClass ) -> contributors .add ( persistentClass .getContributor () )
337- );
338-
339- for ( Namespace namespace : database .getNamespaces () ) {
340- for ( Table table : namespace .getTables () ) {
328+ entityBindingMap .forEach ( (s , persistentClass )
329+ -> contributors .add ( persistentClass .getContributor () ) );
330+ for ( var namespace : database .getNamespaces () ) {
331+ for ( var table : namespace .getTables () ) {
341332 contributors .add ( table .getContributor () );
342333 }
343-
344- for ( Sequence sequence : namespace .getSequences () ) {
334+ for ( var sequence : namespace .getSequences () ) {
345335 contributors .add ( sequence .getContributor () );
346336 }
347337 }
348-
349338 return contributors ;
350339 }
351340
352341 @ Override
353342 public java .util .Collection <Table > collectTableMappings () {
354- ArrayList <Table > tables = new ArrayList <>();
355- for ( Namespace namespace : database .getNamespaces () ) {
343+ final ArrayList <Table > tables = new ArrayList <>();
344+ for ( var namespace : database .getNamespaces () ) {
356345 tables .addAll ( namespace .getTables () );
357346 }
358347 return tables ;
@@ -370,27 +359,27 @@ public NamedObjectRepository buildNamedQueryRepository() {
370359
371360 @ Override
372361 public void orderColumns (boolean forceOrdering ) {
373- final ColumnOrderingStrategy columnOrderingStrategy = metadataBuildingOptions .getColumnOrderingStrategy ();
362+ final var columnOrderingStrategy = metadataBuildingOptions .getColumnOrderingStrategy ();
374363 // No need to order columns when using the no-op strategy
375364 if ( columnOrderingStrategy != ColumnOrderingStrategyLegacy .INSTANCE ) {
376365 final boolean shouldOrderTableColumns = forceOrdering || shouldOrderTableColumns ();
377- for ( Namespace namespace : database .getNamespaces () ) {
366+ for ( var namespace : database .getNamespaces () ) {
378367 if ( shouldOrderTableColumns ) {
379- for ( Table table : namespace .getTables () ) {
368+ for ( var table : namespace .getTables () ) {
380369 handleTable ( table , columnOrderingStrategy );
381370 handlePrimaryKey ( table , columnOrderingStrategy );
382371 handleForeignKeys ( table , columnOrderingStrategy );
383372 }
384373 }
385- for ( UserDefinedType userDefinedType : namespace .getUserDefinedTypes () ) {
374+ for ( var userDefinedType : namespace .getUserDefinedTypes () ) {
386375 handleUDT ( userDefinedType , columnOrderingStrategy );
387376 }
388377 }
389378 }
390379 }
391380
392381 private void handleTable (Table table , ColumnOrderingStrategy columnOrderingStrategy ) {
393- final List < Column > tableColumns = columnOrderingStrategy .orderTableColumns ( table , this );
382+ final var tableColumns = columnOrderingStrategy .orderTableColumns ( table , this );
394383 if ( tableColumns != null ) {
395384 table .reorderColumns ( tableColumns );
396385 }
@@ -399,7 +388,7 @@ private void handleTable(Table table, ColumnOrderingStrategy columnOrderingStrat
399388 private void handleUDT (UserDefinedType userDefinedType , ColumnOrderingStrategy columnOrderingStrategy ) {
400389 if ( userDefinedType instanceof UserDefinedObjectType objectType
401390 && objectType .getColumns ().size () > 1 ) {
402- final List < Column > objectTypeColumns =
391+ final var objectTypeColumns =
403392 columnOrderingStrategy .orderUserDefinedTypeColumns ( objectType , this );
404393 if ( objectTypeColumns != null ) {
405394 objectType .reorderColumns ( objectTypeColumns );
@@ -408,16 +397,16 @@ private void handleUDT(UserDefinedType userDefinedType, ColumnOrderingStrategy c
408397 }
409398
410399 private void handleForeignKeys (Table table , ColumnOrderingStrategy columnOrderingStrategy ) {
411- for ( ForeignKey foreignKey : table .getForeignKeyCollection () ) {
412- final List < Column > columns = foreignKey .getColumns ();
400+ for ( var foreignKey : table .getForeignKeyCollection () ) {
401+ final var columns = foreignKey .getColumns ();
413402 if ( columns .size () > 1 ) {
414403 if ( foreignKey .getReferencedColumns ().isEmpty () ) {
415- final PrimaryKey targetPrimaryKey =
404+ final var targetPrimaryKey =
416405 foreignKey .getReferencedTable ().getPrimaryKey ();
417406 // Make sure we order the columns of the primary key first,
418407 // so that foreign key ordering can rely on this
419408 if ( targetPrimaryKey .getOriginalOrder () == null ) {
420- final List < Column > primaryKeyColumns =
409+ final var primaryKeyColumns =
421410 columnOrderingStrategy .orderConstraintColumns ( targetPrimaryKey , this );
422411 if ( primaryKeyColumns != null ) {
423412 targetPrimaryKey .reorderColumns ( primaryKeyColumns );
@@ -427,7 +416,7 @@ private void handleForeignKeys(Table table, ColumnOrderingStrategy columnOrderin
427416 // Patch up the order of foreign keys based on new order of the target primary key
428417 final int [] originalPrimaryKeyOrder = targetPrimaryKey .getOriginalOrder ();
429418 if ( originalPrimaryKeyOrder != null ) {
430- final ArrayList < Column > foreignKeyColumnsCopy = new ArrayList <>( columns );
419+ final var foreignKeyColumnsCopy = new ArrayList <>( columns );
431420 for ( int i = 0 ; i < foreignKeyColumnsCopy .size (); i ++ ) {
432421 columns .set ( i , foreignKeyColumnsCopy .get ( originalPrimaryKeyOrder [i ] ) );
433422 }
@@ -438,10 +427,11 @@ private void handleForeignKeys(Table table, ColumnOrderingStrategy columnOrderin
438427 }
439428
440429 private void handlePrimaryKey (Table table , ColumnOrderingStrategy columnOrderingStrategy ) {
441- final PrimaryKey primaryKey = table .getPrimaryKey ();
442- if ( primaryKey != null && primaryKey .getColumns ()
443- .size () > 1 && primaryKey .getOriginalOrder () == null ) {
444- final List <Column > primaryKeyColumns =
430+ final var primaryKey = table .getPrimaryKey ();
431+ if ( primaryKey != null
432+ && primaryKey .getColumns ().size () > 1
433+ && primaryKey .getOriginalOrder () == null ) {
434+ final var primaryKeyColumns =
445435 columnOrderingStrategy .orderConstraintColumns ( primaryKey , this );
446436 if ( primaryKeyColumns != null ) {
447437 primaryKey .reorderColumns ( primaryKeyColumns );
@@ -454,7 +444,7 @@ private boolean shouldOrderTableColumns() {
454444 metadataBuildingOptions .getServiceRegistry ()
455445 .requireService ( ConfigurationService .class )
456446 .getSettings ();
457- for ( ActionGrouping grouping : ActionGrouping .interpret ( this , settings ) ) {
447+ for ( var grouping : ActionGrouping .interpret ( this , settings ) ) {
458448 if ( isColumnOrderingRelevant ( grouping .scriptAction () )
459449 || isColumnOrderingRelevant ( grouping .databaseAction () ) ) {
460450 return true ;
@@ -472,11 +462,11 @@ private static boolean isColumnOrderingRelevant(Action grouping) {
472462
473463 @ Override
474464 public void validate () throws MappingException {
475- for ( PersistentClass entityBinding : this .getEntityBindings () ) {
465+ for ( var entityBinding : this .getEntityBindings () ) {
476466 entityBinding .validate ( this );
477467 }
478468
479- for ( Collection collectionBinding : this .getCollectionBindings () ) {
469+ for ( var collectionBinding : this .getCollectionBindings () ) {
480470 collectionBinding .validate ( this );
481471 }
482472 }
@@ -491,15 +481,15 @@ public Set<MappedSuperclass> getMappedSuperclassMappingsCopy() {
491481 @ Override
492482 public void initSessionFactory (SessionFactoryImplementor sessionFactory ) {
493483 // must not use BootstrapContext services here
494- final ServiceRegistryImplementor registry = sessionFactory .getServiceRegistry ();
484+ final var registry = sessionFactory .getServiceRegistry ();
495485 assert registry != null ;
496- final ConfigurationService configurationService = registry .requireService ( ConfigurationService .class );
497- final ClassLoaderService classLoaderService = registry .requireService ( ClassLoaderService .class );
498- final EventListenerRegistry eventListenerRegistry = sessionFactory .getEventListenerRegistry ();
486+ final var configurationService = registry .requireService ( ConfigurationService .class );
487+ final var classLoaderService = registry .requireService ( ClassLoaderService .class );
488+ final var eventListenerRegistry = sessionFactory .getEventListenerRegistry ();
499489 configurationService .getSettings ().forEach ( (propertyName , value ) -> {
500490 if ( propertyName .startsWith ( EVENT_LISTENER_PREFIX ) ) {
501491 final String eventTypeName = propertyName .substring ( EVENT_LISTENER_PREFIX .length () + 1 );
502- final EventType <?> eventType = EventType .resolveEventTypeByName ( eventTypeName );
492+ final var eventType = EventType .resolveEventTypeByName ( eventTypeName );
503493 final String listeners = (String ) value ;
504494 appendListeners ( eventListenerRegistry , classLoaderService , listeners , eventType );
505495 }
@@ -511,7 +501,7 @@ private <T> void appendListeners(
511501 ClassLoaderService classLoaderService ,
512502 String listeners ,
513503 EventType <T > eventType ) {
514- final EventListenerGroup < T > eventListenerGroup = eventListenerRegistry .getEventListenerGroup ( eventType );
504+ final var eventListenerGroup = eventListenerRegistry .getEventListenerGroup ( eventType );
515505 for ( String listenerImpl : splitAtCommas ( listeners ) ) {
516506 @ SuppressWarnings ("unchecked" )
517507 T listener = (T ) instantiate ( listenerImpl , classLoaderService );
@@ -551,36 +541,36 @@ public DiscriminatorType<?> resolveEmbeddableDiscriminatorType(
551541
552542 @ Override
553543 public org .hibernate .type .Type getIdentifierType (String entityName ) throws MappingException {
554- final PersistentClass pc = entityBindingMap .get ( entityName );
555- if ( pc == null ) {
544+ final var persistentClass = entityBindingMap .get ( entityName );
545+ if ( persistentClass == null ) {
556546 throw new MappingException ( "Persistent class not known: " + entityName );
557547 }
558- return pc .getIdentifier ().getType ();
548+ return persistentClass .getIdentifier ().getType ();
559549 }
560550
561551 @ Override
562552 public String getIdentifierPropertyName (String entityName ) throws MappingException {
563- final PersistentClass pc = entityBindingMap .get ( entityName );
564- if ( pc == null ) {
553+ final var persistentClass = entityBindingMap .get ( entityName );
554+ if ( persistentClass == null ) {
565555 throw new MappingException ( "Persistent class not known: " + entityName );
566556 }
567- if ( !pc .hasIdentifierProperty () ) {
557+ if ( !persistentClass .hasIdentifierProperty () ) {
568558 return null ;
569559 }
570- return pc .getIdentifierProperty ().getName ();
560+ return persistentClass .getIdentifierProperty ().getName ();
571561 }
572562
573563 @ Override
574564 public org .hibernate .type .Type getReferencedPropertyType (String entityName , String propertyName ) throws MappingException {
575- final PersistentClass pc = entityBindingMap .get ( entityName );
576- if ( pc == null ) {
565+ final var persistentClass = entityBindingMap .get ( entityName );
566+ if ( persistentClass == null ) {
577567 throw new MappingException ( "Persistent class not known: " + entityName );
578568 }
579- final Property prop = pc .getReferencedProperty ( propertyName );
580- if ( prop == null ) {
569+ final var referencedProperty = persistentClass .getReferencedProperty ( propertyName );
570+ if ( referencedProperty == null ) {
581571 throw new MappingException ( "Property not known: " + entityName + '.' + propertyName );
582572 }
583- return prop .getType ();
573+ return referencedProperty .getType ();
584574 }
585575
586576 //Specific for copies only:
0 commit comments