166166import org .hibernate .internal .util .StringHelper ;
167167import org .hibernate .internal .util .collections .CollectionHelper ;
168168import org .hibernate .mapping .BasicValue ;
169- import org .hibernate .mapping .CheckConstraint ;
170169import org .hibernate .mapping .Collection ;
171170import org .hibernate .mapping .Column ;
172171import org .hibernate .mapping .Component ;
@@ -227,16 +226,15 @@ public static List<Binding<JaxbEntityMappingsImpl>> transform(
227226 MetadataImplementor bootModel ,
228227 UnsupportedFeatureHandling unsupportedFeatureHandling ) {
229228 // perform a first pass over the hbm.xml bindings building much of the transformation-state
230- final TransformationState transformationState = new TransformationState ();
231- final List <Binding <JaxbEntityMappingsImpl >> transformations =
232- XmlPreprocessor .preprocessHbmXml ( hbmXmlBindings , transformationState );
229+ final var transformationState = new TransformationState ();
230+ final var transformations = XmlPreprocessor .preprocessHbmXml ( hbmXmlBindings , transformationState );
233231
234232 // build and perform a pass over the boot model building the rest of the transformation-state
235233 BootModelPreprocessor .preprocessBooModel ( bootModel , transformationState );
236234
237235 // now we are ready to fully build the mapping.xml transformations
238236 for ( int i = 0 ; i < hbmXmlBindings .size (); i ++ ) {
239- final HbmXmlTransformer hbmXmlTransformer = new HbmXmlTransformer (
237+ final var hbmXmlTransformer = new HbmXmlTransformer (
240238 hbmXmlBindings .get ( i ),
241239 transformations .get ( i ),
242240 transformationState ,
@@ -275,8 +273,8 @@ private HbmXmlTransformer(
275273
276274
277275 private void performTransformation () {
278- final JaxbHbmHibernateMapping hbmXmlRoot = hbmXmlBinding .getRoot ();
279- final JaxbEntityMappingsImpl mappingXmlRoot = mappingXmlBinding .getRoot ();
276+ final var hbmXmlRoot = hbmXmlBinding .getRoot ();
277+ final var mappingXmlRoot = mappingXmlBinding .getRoot ();
280278
281279 TransformationHelper .transfer ( hbmXmlRoot ::getPackage , mappingXmlRoot ::setPackage );
282280 TransformationHelper .transfer ( hbmXmlRoot ::getCatalog , mappingXmlRoot ::setCatalog );
@@ -295,53 +293,53 @@ private void performTransformation() {
295293
296294 hbmXmlRoot .getClazz ().forEach ( (hbmEntity ) -> {
297295 final String entityName = TransformationHelper .determineEntityName ( hbmEntity , hbmXmlRoot );
298- final JaxbEntityImpl mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
299- final EntityTypeInfo bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
296+ final var mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
297+ final var bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
300298 assert mappingEntity != null : "Unable to locate JaxbEntityImpl for " + entityName ;
301- assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
299+ assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
302300
303301 transferRootEntity ( hbmEntity , mappingEntity , bootEntityInfo );
304302 } );
305303
306304 hbmXmlRoot .getSubclass ().forEach ( (hbmSubclass ) -> {
307305 final String entityName = TransformationHelper .determineEntityName ( hbmSubclass , hbmXmlRoot );
308- final JaxbEntityImpl mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
309- final EntityTypeInfo bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
306+ final var mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
307+ final var bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
310308 assert mappingEntity != null : "Unable to locate JaxbEntityImpl for " + entityName ;
311- assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
309+ assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
312310
313311 transferDiscriminatorSubclass ( hbmSubclass , mappingEntity , bootEntityInfo );
314312
315313 final String rootEntityName = bootEntityInfo .getPersistentClass ().getRootClass ().getEntityName ();
316- final JaxbEntityImpl rootMappingEntity = transformationState .getMappingEntityByName ().get ( rootEntityName );
314+ final var rootMappingEntity = transformationState .getMappingEntityByName ().get ( rootEntityName );
317315 defineInheritance ( rootMappingEntity , InheritanceType .SINGLE_TABLE );
318316 } );
319317
320318 hbmXmlRoot .getJoinedSubclass ().forEach ( (hbmSubclass ) -> {
321319 final String entityName = TransformationHelper .determineEntityName ( hbmSubclass , hbmXmlRoot );
322- final JaxbEntityImpl mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
323- final EntityTypeInfo bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
320+ final var mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
321+ final var bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
324322 assert mappingEntity != null : "Unable to locate JaxbEntityImpl for " + entityName ;
325- assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
323+ assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
326324
327325 transferJoinedSubclass ( hbmSubclass , mappingEntity , bootEntityInfo );
328326
329327 final String rootEntityName = bootEntityInfo .getPersistentClass ().getRootClass ().getEntityName ();
330- final JaxbEntityImpl rootMappingEntity = transformationState .getMappingEntityByName ().get ( rootEntityName );
328+ final var rootMappingEntity = transformationState .getMappingEntityByName ().get ( rootEntityName );
331329 defineInheritance ( rootMappingEntity , InheritanceType .JOINED );
332330 } );
333331
334332 hbmXmlRoot .getUnionSubclass ().forEach ( (hbmSubclass ) -> {
335333 final String entityName = TransformationHelper .determineEntityName ( hbmSubclass , hbmXmlRoot );
336- final JaxbEntityImpl mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
337- final EntityTypeInfo bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
334+ final var mappingEntity = transformationState .getMappingEntityByName ().get ( entityName );
335+ final var bootEntityInfo = transformationState .getEntityInfoByName ().get ( entityName );
338336 assert mappingEntity != null : "Unable to locate JaxbEntityImpl for " + entityName ;
339- assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
337+ assert bootEntityInfo != null : "Unable to locate EntityTypeInfo for " + entityName ;
340338
341339 transferUnionSubclass ( hbmSubclass , mappingEntity , bootEntityInfo );
342340
343341 final String rootEntityName = bootEntityInfo .getPersistentClass ().getRootClass ().getEntityName ();
344- final JaxbEntityImpl rootMappingEntity = transformationState .getMappingEntityByName ().get ( rootEntityName );
342+ final var rootMappingEntity = transformationState .getMappingEntityByName ().get ( rootEntityName );
345343 defineInheritance ( rootMappingEntity , InheritanceType .TABLE_PER_CLASS );
346344 } );
347345
@@ -352,10 +350,10 @@ private void performTransformation() {
352350
353351 private static void dumpTransformed (Origin origin , JaxbEntityMappingsImpl ormRoot ) {
354352 try {
355- JAXBContext ctx = JAXBContext .newInstance ( JaxbEntityMappingsImpl .class );
356- Marshaller marshaller = ctx .createMarshaller ();
353+ var ctx = JAXBContext .newInstance ( JaxbEntityMappingsImpl .class );
354+ var marshaller = ctx .createMarshaller ();
357355 marshaller .setProperty ( Marshaller .JAXB_FORMATTED_OUTPUT , true );
358- final StringWriter stringWriter = new StringWriter ();
356+ final var stringWriter = new StringWriter ();
359357 marshaller .marshal ( ormRoot , stringWriter );
360358 TRANSFORMATION_LOGGER .debugf ( "Transformed hbm.xml (%s):\n %s" , origin , stringWriter .toString () );
361359 }
@@ -376,8 +374,8 @@ private void transferRootEntity(
376374
377375 applyTable ( entityInfo .getPersistentClass (), mappingEntity );
378376
379- for ( JaxbHbmSynchronizeType hbmSync : hbmClass .getSynchronize () ) {
380- final JaxbSynchronizedTableImpl sync = new JaxbSynchronizedTableImpl ();
377+ for ( var hbmSync : hbmClass .getSynchronize () ) {
378+ final var sync = new JaxbSynchronizedTableImpl ();
381379 sync .setTable ( hbmSync .getTable () );
382380 mappingEntity .getSynchronizeTables ().add ( sync );
383381 }
@@ -422,55 +420,57 @@ private void transferRootEntity(
422420 transformEntityCaching ( hbmClass , mappingEntity );
423421 }
424422
425- for ( JaxbHbmNamedQueryType hbmQuery : hbmClass .getQuery () ) {
426- mappingEntity .getNamedQueries ().add ( transformNamedQuery ( hbmQuery , mappingEntity .getName () + "." + hbmQuery .getName () ) );
423+ for ( var hbmQuery : hbmClass .getQuery () ) {
424+ final String name = mappingEntity .getName () + "." + hbmQuery .getName ();
425+ mappingEntity .getNamedQueries ().add ( transformNamedQuery ( hbmQuery , name ) );
427426 }
428427
429- for ( JaxbHbmNamedNativeQueryType hbmQuery : hbmClass .getSqlQuery () ) {
430- mappingEntity .getNamedNativeQueries ().add (
431- transformNamedNativeQuery ( hbmQuery , mappingEntity .getName () + "." + hbmQuery .getName () )
432- );
428+ for ( var hbmQuery : hbmClass .getSqlQuery () ) {
429+ final String name = mappingEntity .getName () + "." + hbmQuery .getName ();
430+ mappingEntity .getNamedNativeQueries ().add ( transformNamedNativeQuery ( hbmQuery , name ) );
433431 }
434432
435- for ( JaxbHbmFilterType hbmFilter : hbmClass .getFilter ()) {
436- mappingEntity .getFilters ().add ( convert ( hbmFilter ) );
433+ final var filters = mappingEntity .getFilters ();
434+ for ( var hbmFilter : hbmClass .getFilter ()) {
435+ filters .add ( convert ( hbmFilter ) );
437436 }
438437
439- for ( JaxbHbmFetchProfileType hbmFetchProfile : hbmClass .getFetchProfile () ) {
440- mappingEntity .getFetchProfiles ().add ( transferFetchProfile ( hbmFetchProfile ) );
438+ final var fetchProfiles = mappingEntity .getFetchProfiles ();
439+ for ( var hbmFetchProfile : hbmClass .getFetchProfile () ) {
440+ fetchProfiles .add ( transferFetchProfile ( hbmFetchProfile ) );
441441 }
442442
443- for ( JaxbHbmDiscriminatorSubclassEntityType hbmSubclass : hbmClass .getSubclass () ) {
443+ for ( var hbmSubclass : hbmClass .getSubclass () ) {
444444 final String subclassEntityName = TransformationHelper .determineEntityName ( hbmSubclass , hbmXmlBinding .getRoot () );
445- final JaxbEntityImpl mappingSubclassEntity = transformationState .getMappingEntityByName ().get ( subclassEntityName );
446- final EntityTypeInfo subclassEntityInfo = transformationState .getEntityInfoByName ().get ( subclassEntityName );
445+ final var mappingSubclassEntity = transformationState .getMappingEntityByName ().get ( subclassEntityName );
446+ final var subclassEntityInfo = transformationState .getEntityInfoByName ().get ( subclassEntityName );
447447 transferDiscriminatorSubclass ( hbmSubclass , mappingSubclassEntity , subclassEntityInfo );
448448 defineInheritance ( mappingEntity , InheritanceType .SINGLE_TABLE );
449449 }
450450
451- for ( JaxbHbmJoinedSubclassEntityType hbmSubclass : hbmClass .getJoinedSubclass () ) {
451+ for ( var hbmSubclass : hbmClass .getJoinedSubclass () ) {
452452 final String subclassEntityName = TransformationHelper .determineEntityName ( hbmSubclass , hbmXmlBinding .getRoot () );
453- final JaxbEntityImpl mappingSubclassEntity = transformationState .getMappingEntityByName ().get ( subclassEntityName );
454- final EntityTypeInfo subclassEntityInfo = transformationState .getEntityInfoByName ().get ( subclassEntityName );
453+ final var mappingSubclassEntity = transformationState .getMappingEntityByName ().get ( subclassEntityName );
454+ final var subclassEntityInfo = transformationState .getEntityInfoByName ().get ( subclassEntityName );
455455 transferJoinedSubclass ( hbmSubclass , mappingSubclassEntity , subclassEntityInfo );
456456 defineInheritance ( mappingEntity , InheritanceType .TABLE_PER_CLASS );
457457 }
458458
459- for (JaxbHbmUnionSubclassEntityType hbmSubclass : hbmClass .getUnionSubclass () ) {
459+ for ( var hbmSubclass : hbmClass .getUnionSubclass () ) {
460460 final String subclassEntityName = TransformationHelper .determineEntityName ( hbmSubclass , hbmXmlBinding .getRoot () );
461- final JaxbEntityImpl mappingSubclassEntity = transformationState .getMappingEntityByName ().get ( subclassEntityName );
462- final EntityTypeInfo subclassEntityInfo = transformationState .getEntityInfoByName ().get ( subclassEntityName );
461+ final var mappingSubclassEntity = transformationState .getMappingEntityByName ().get ( subclassEntityName );
462+ final var subclassEntityInfo = transformationState .getEntityInfoByName ().get ( subclassEntityName );
463463 transferUnionSubclass ( hbmSubclass , mappingSubclassEntity , subclassEntityInfo );
464464 defineInheritance ( mappingEntity , InheritanceType .JOINED );
465465 }
466466
467- for ( JaxbHbmNamedQueryType hbmQuery : hbmClass .getQuery () ) {
467+ for ( var hbmQuery : hbmClass .getQuery () ) {
468468 // Tests implied this was the case...
469469 final String name = hbmClass .getName () + "." + hbmQuery .getName ();
470470 mappingXmlBinding .getRoot ().getNamedQueries ().add ( transformNamedQuery ( hbmQuery , name ) );
471471 }
472472
473- for ( JaxbHbmNamedNativeQueryType hbmQuery : hbmClass .getSqlQuery () ) {
473+ for ( var hbmQuery : hbmClass .getSqlQuery () ) {
474474 // Tests implied this was the case...
475475 final String name = hbmClass .getName () + "." + hbmQuery .getName ();
476476 mappingXmlBinding .getRoot ().getNamedNativeQueries ().add ( transformNamedNativeQuery ( hbmQuery , name ) );
@@ -503,10 +503,10 @@ private void transferDiscriminatorSubclass(
503503 transferBaseEntityAttributes ( hbmSubclass , subclassEntity , subclassEntityInfo );
504504
505505 if ( !hbmSubclass .getSubclass ().isEmpty () ) {
506- for ( JaxbHbmDiscriminatorSubclassEntityType nestedHbmSubclass : hbmSubclass .getSubclass () ) {
506+ for ( var nestedHbmSubclass : hbmSubclass .getSubclass () ) {
507507 final String nestedSubclassEntityName = TransformationHelper .determineEntityName ( nestedHbmSubclass , hbmXmlBinding .getRoot () );
508- final JaxbEntityImpl nestedSubclassSubclassEntity = transformationState .getMappingEntityByName ().get ( nestedSubclassEntityName );
509- final EntityTypeInfo nestedSubclassInfo = transformationState .getEntityInfoByName ().get ( nestedSubclassEntityName );
508+ final var nestedSubclassSubclassEntity = transformationState .getMappingEntityByName ().get ( nestedSubclassEntityName );
509+ final var nestedSubclassInfo = transformationState .getEntityInfoByName ().get ( nestedSubclassEntityName );
510510 transferDiscriminatorSubclass ( nestedHbmSubclass , nestedSubclassSubclassEntity , nestedSubclassInfo );
511511 }
512512 }
@@ -523,20 +523,20 @@ private void transferJoinedSubclass(
523523
524524 applyTable ( subclassEntityInfo .getPersistentClass (), subclassEntity );
525525
526- final JaxbHbmKeyType key = hbmSubclass .getKey ();
526+ final var key = hbmSubclass .getKey ();
527527 if ( key != null ) {
528- final JaxbPrimaryKeyJoinColumnImpl joinColumn = new JaxbPrimaryKeyJoinColumnImpl ();
528+ final var joinColumn = new JaxbPrimaryKeyJoinColumnImpl ();
529529 // todo (7.0) : formula and multiple columns
530530 joinColumn .setName ( key .getColumnAttribute () );
531531 subclassEntity .getPrimaryKeyJoinColumns ().add ( joinColumn );
532532 joinColumn .setForeignKey ( transformForeignKey ( key .getForeignKey () ) );
533533 }
534534
535535 if ( !hbmSubclass .getJoinedSubclass ().isEmpty () ) {
536- for ( JaxbHbmJoinedSubclassEntityType nestedHbmSubclass : hbmSubclass .getJoinedSubclass () ) {
536+ for ( var nestedHbmSubclass : hbmSubclass .getJoinedSubclass () ) {
537537 final String nestedSubclassEntityName = TransformationHelper .determineEntityName ( nestedHbmSubclass , hbmXmlBinding .getRoot () );
538- final JaxbEntityImpl nestedSubclassSubclassEntity = transformationState .getMappingEntityByName ().get ( nestedSubclassEntityName );
539- final EntityTypeInfo nestedSubclassInfo = transformationState .getEntityInfoByName ().get ( nestedSubclassEntityName );
538+ final var nestedSubclassSubclassEntity = transformationState .getMappingEntityByName ().get ( nestedSubclassEntityName );
539+ final var nestedSubclassInfo = transformationState .getEntityInfoByName ().get ( nestedSubclassEntityName );
540540 transferJoinedSubclass ( nestedHbmSubclass , nestedSubclassSubclassEntity , nestedSubclassInfo );
541541 }
542542 }
@@ -555,10 +555,10 @@ private void transferUnionSubclass(
555555 applyTable ( subclassEntityInfo .getPersistentClass (), subclassEntity );
556556
557557 if ( !hbmSubclass .getUnionSubclass ().isEmpty () ) {
558- for ( JaxbHbmUnionSubclassEntityType nestedHbmSubclass : hbmSubclass .getUnionSubclass () ) {
558+ for ( var nestedHbmSubclass : hbmSubclass .getUnionSubclass () ) {
559559 final String nestedSubclassEntityName = TransformationHelper .determineEntityName ( nestedHbmSubclass , hbmXmlBinding .getRoot () );
560- final JaxbEntityImpl nestedSubclassSubclassEntity = transformationState .getMappingEntityByName ().get ( nestedSubclassEntityName );
561- final EntityTypeInfo nestedSubclassInfo = transformationState .getEntityInfoByName ().get ( nestedSubclassEntityName );
560+ final var nestedSubclassSubclassEntity = transformationState .getMappingEntityByName ().get ( nestedSubclassEntityName );
561+ final var nestedSubclassInfo = transformationState .getEntityInfoByName ().get ( nestedSubclassEntityName );
562562 transferUnionSubclass ( nestedHbmSubclass , nestedSubclassSubclassEntity , nestedSubclassInfo );
563563 }
564564 }
@@ -570,7 +570,7 @@ private void transferBaseEntityInformation(
570570 EntityTypeInfo bootEntityInfo ) {
571571 mappingEntity .setMetadataComplete ( true );
572572
573- final PersistentClass persistentClass = bootEntityInfo .getPersistentClass ();
573+ final var persistentClass = bootEntityInfo .getPersistentClass ();
574574 if ( persistentClass .getSuperclass () != null ) {
575575 mappingEntity .setExtends ( persistentClass .getSuperclass ().getEntityName () );
576576 }
@@ -621,21 +621,19 @@ private void applyBasicTypeMapping(
621621 }
622622 else if ( type instanceof CustomType <?> ) {
623623 if ( isNotEmpty ( hbmTypeAttribute ) ) {
624- final JaxbUserTypeImpl typeNode = interpretBasicType (
624+ jaxbBasicMapping . setType ( interpretBasicType (
625625 hbmTypeAttribute ,
626626 null ,
627627 transformationState .getTypeDefMap ().get ( hbmTypeAttribute )
628- );
629- jaxbBasicMapping .setType ( typeNode );
628+ ) );
630629 }
631630
632631 if ( hbmType != null ) {
633- final JaxbUserTypeImpl typeNode = interpretBasicType (
632+ jaxbBasicMapping . setType ( interpretBasicType (
634633 hbmType .getName (),
635634 hbmType ,
636635 transformationState .getTypeDefMap ().get ( hbmType .getName () )
637- );
638- jaxbBasicMapping .setType ( typeNode );
636+ ) );
639637 }
640638 }
641639 else if ( type instanceof ConvertedBasicType <?> convertedType ) {
@@ -659,7 +657,7 @@ else if ( table.isView() ) {
659657 jaxbEntity .setTableExpression ( table .getViewQuery () );
660658 }
661659 else {
662- final JaxbTableImpl jaxbTable = new JaxbTableImpl ();
660+ final var jaxbTable = new JaxbTableImpl ();
663661 jaxbEntity .setTable ( jaxbTable );
664662 jaxbTable .setName ( table .getName () );
665663 jaxbTable .setComment ( table .getComment () );
@@ -671,8 +669,8 @@ private static void transferBaseTableInfo(Table table, JaxbTableMapping jaxbTabl
671669 jaxbTableMapping .setCatalog ( table .getCatalog () );
672670 jaxbTableMapping .setSchema ( table .getSchema () );
673671
674- for ( CheckConstraint check : table .getChecks () ) {
675- final JaxbCheckConstraintImpl jaxbCheckConstraint = new JaxbCheckConstraintImpl ();
672+ for ( var check : table .getChecks () ) {
673+ final var jaxbCheckConstraint = new JaxbCheckConstraintImpl ();
676674 jaxbTableMapping .getCheckConstraints ().add ( jaxbCheckConstraint );
677675 jaxbCheckConstraint .setName ( check .getName () );
678676 jaxbCheckConstraint .setConstraint ( check .getConstraint () );
0 commit comments