4444import static org .hibernate .boot .model .internal .AnnotatedClassType .ENTITY ;
4545import static org .hibernate .boot .model .internal .EntityBinder .bindEntityClass ;
4646import static org .hibernate .boot .model .internal .FilterDefBinder .bindFilterDefs ;
47+ import static org .hibernate .boot .model .internal .GeneratorBinder .registerGlobalGenerators ;
4748import static org .hibernate .boot .model .internal .GeneratorParameters .interpretSequenceGenerator ;
4849import static org .hibernate .boot .model .internal .GeneratorParameters .interpretTableGenerator ;
4950import static org .hibernate .boot .model .internal .InheritanceState .getInheritanceStateOfSuperEntity ;
5051import static org .hibernate .boot .model .internal .InheritanceState .getSuperclassInheritanceState ;
5152import static org .hibernate .boot .BootLogging .BOOT_LOGGER ;
53+ import static org .hibernate .boot .model .internal .QueryBinder .bindNamedStoredProcedureQuery ;
54+ import static org .hibernate .boot .model .internal .QueryBinder .bindNativeQuery ;
55+ import static org .hibernate .boot .model .internal .QueryBinder .bindQuery ;
56+ import static org .hibernate .boot .model .internal .QueryBinder .bindSqlResultSetMapping ;
5257import static org .hibernate .internal .util .StringHelper .unqualify ;
5358import static org .hibernate .mapping .MetadataSource .ANNOTATIONS ;
5459
@@ -98,23 +103,23 @@ public static void bindDefaults(MetadataBuildingContext context) {
98103 // result-set-mappings
99104
100105 globalRegistrations .getSqlResultSetMappingRegistrations ().forEach ( (name , mappingRegistration ) -> {
101- QueryBinder . bindSqlResultSetMapping ( mappingRegistration .configuration (), context , true );
106+ bindSqlResultSetMapping ( mappingRegistration .configuration (), context , true );
102107 } );
103108
104109
105110 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106111 // queries
107112
108113 globalRegistrations .getNamedQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
109- QueryBinder . bindQuery ( queryRegistration .configuration (), context , true , null );
114+ bindQuery ( queryRegistration .configuration (), context , true , null );
110115 } );
111116
112117 globalRegistrations .getNamedNativeQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
113- QueryBinder . bindNativeQuery ( queryRegistration .configuration (), context , null , true );
118+ bindNativeQuery ( queryRegistration .configuration (), context , null , true );
114119 } );
115120
116121 globalRegistrations .getNamedStoredProcedureQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
117- QueryBinder . bindNamedStoredProcedureQuery ( queryRegistration .configuration (), context , true );
122+ bindNamedStoredProcedureQuery ( queryRegistration .configuration (), context , true );
118123 } );
119124
120125 }
@@ -130,7 +135,7 @@ public static void bindPackage(ClassLoaderService cls, String packageName, Metad
130135 modelsContext ( context ).getClassDetailsRegistry ()
131136 .resolveClassDetails ( pack .getName () + ".package-info" );
132137
133- GeneratorBinder . registerGlobalGenerators ( packageInfo , context );
138+ registerGlobalGenerators ( packageInfo , context );
134139
135140 bindTypeDescriptorRegistrations ( packageInfo , context );
136141 bindEmbeddableInstantiatorRegistrations ( packageInfo , context );
@@ -153,7 +158,7 @@ private static void bindNamedEntityGraphs(ClassDetails packageInfoClassDetails,
153158 packageInfoClassDetails .forEachRepeatedAnnotationUsages (
154159 HibernateAnnotations .NAMED_ENTITY_GRAPH ,
155160 modelsContext ( context ),
156- ( annotation ) -> collector .addNamedEntityGraph ( new NamedEntityGraphDefinition (
161+ annotation -> collector .addNamedEntityGraph ( new NamedEntityGraphDefinition (
157162 annotation .name (), null ,
158163 NamedEntityGraphDefinition .Source .PARSED ,
159164 new NamedGraphCreatorParsed ( annotation )
@@ -172,13 +177,13 @@ private static void bindNamedHibernateQueries(AnnotationTarget annotationTarget,
172177 annotationTarget .forEachRepeatedAnnotationUsages (
173178 HibernateAnnotations .NAMED_QUERY ,
174179 sourceModelContext ,
175- (usage ) -> QueryBinder . bindQuery ( usage , context , annotationTarget )
180+ (usage ) -> bindQuery ( usage , context , annotationTarget )
176181 );
177182
178183 annotationTarget .forEachRepeatedAnnotationUsages (
179184 HibernateAnnotations .NAMED_NATIVE_QUERY ,
180185 sourceModelContext ,
181- (usage ) -> QueryBinder . bindNativeQuery ( usage , context , annotationTarget )
186+ (usage ) -> bindNativeQuery ( usage , context , annotationTarget )
182187 );
183188 }
184189
@@ -188,25 +193,25 @@ private static void bindNamedJpaQueries(AnnotationTarget annotationTarget, Metad
188193 annotationTarget .forEachRepeatedAnnotationUsages (
189194 JpaAnnotations .SQL_RESULT_SET_MAPPING ,
190195 sourceModelContext ,
191- (usage ) -> QueryBinder . bindSqlResultSetMapping ( usage , context ,false )
196+ (usage ) -> bindSqlResultSetMapping ( usage , context ,false )
192197 );
193198
194199 annotationTarget .forEachRepeatedAnnotationUsages (
195200 JpaAnnotations .NAMED_QUERY ,
196201 sourceModelContext ,
197- (usage ) -> QueryBinder . bindQuery ( usage , context , false , annotationTarget )
202+ (usage ) -> bindQuery ( usage , context , false , annotationTarget )
198203 );
199204
200205 annotationTarget .forEachRepeatedAnnotationUsages (
201206 JpaAnnotations .NAMED_NATIVE_QUERY ,
202207 sourceModelContext ,
203- (usage ) -> QueryBinder . bindNativeQuery ( usage , context , annotationTarget , false )
208+ (usage ) -> bindNativeQuery ( usage , context , annotationTarget , false )
204209 );
205210
206211 annotationTarget .forEachRepeatedAnnotationUsages (
207212 JpaAnnotations .NAMED_STORED_PROCEDURE_QUERY ,
208213 sourceModelContext ,
209- (usage ) -> QueryBinder . bindNamedStoredProcedureQuery ( usage , context , false )
214+ (usage ) -> bindNamedStoredProcedureQuery ( usage , context , false )
210215 );
211216 }
212217
@@ -292,7 +297,7 @@ private static void handleJdbcTypeRegistration(
292297 MetadataBuildingContext context ,
293298 ManagedBeanRegistry managedBeanRegistry ,
294299 JdbcTypeRegistration annotation ) {
295- final JdbcType jdbcType = getBean ( context , managedBeanRegistry , annotation .value () );
300+ final var jdbcType = getBean ( context , managedBeanRegistry , annotation .value () );
296301 context .getMetadataCollector ()
297302 .addJdbcTypeRegistration ( jdbcTypeCode ( annotation , jdbcType ), jdbcType );
298303 }
@@ -417,9 +422,9 @@ private static void bindFetchProfile(FetchProfile fetchProfile, MetadataBuilding
417422 final String name = fetchProfile .name ();
418423 if ( reuseOrCreateFetchProfile ( context , name ) ) {
419424 for ( var fetchOverride : fetchProfile .fetchOverrides () ) {
420- final FetchType type = fetchOverride .fetch ();
421- final FetchMode mode = fetchOverride .mode ();
422- if ( type == FetchType .LAZY && mode == FetchMode .JOIN ) {
425+ final FetchType fetchType = fetchOverride .fetch ();
426+ final FetchMode fetchMode = fetchOverride .mode ();
427+ if ( fetchType == FetchType .LAZY && fetchMode == FetchMode .JOIN ) {
423428 throw new AnnotationException (
424429 "Fetch profile '" + name
425430 + "' has a '@FetchOverride' with 'fetch=LAZY' and 'mode=JOIN'"
@@ -461,25 +466,25 @@ public static Map<ClassDetails, InheritanceState> buildInheritanceStates(
461466 MetadataBuildingContext buildingContext ) {
462467 final Map <ClassDetails , InheritanceState > inheritanceStatePerClass = new HashMap <>( orderedClasses .size () );
463468 final var collector = buildingContext .getMetadataCollector ();
464- for ( ClassDetails clazz : orderedClasses ) {
465- final var superclassState = getSuperclassInheritanceState ( clazz , inheritanceStatePerClass );
466- final var state = new InheritanceState ( clazz , inheritanceStatePerClass , buildingContext );
467- final var classType = collector .getClassType ( clazz );
468- if ( classType == EMBEDDABLE && !clazz .hasDirectAnnotationUsage ( Imported .class ) ) {
469- final String className = clazz .getName ();
469+ for ( var classDetails : orderedClasses ) {
470+ final var superclassState = getSuperclassInheritanceState ( classDetails , inheritanceStatePerClass );
471+ final var state = new InheritanceState ( classDetails , inheritanceStatePerClass , buildingContext );
472+ final var classType = collector .getClassType ( classDetails );
473+ if ( classType == EMBEDDABLE && !classDetails .hasDirectAnnotationUsage ( Imported .class ) ) {
474+ final String className = classDetails .getName ();
470475 collector .addImport ( unqualify ( className ), className );
471476 }
472477 if ( superclassState != null ) {
473478 //the classes are ordered thus preventing an NPE
474479 superclassState .setHasSiblings ( true );
475- final var superEntityState = getInheritanceStateOfSuperEntity ( clazz , inheritanceStatePerClass );
480+ final var superEntityState = getInheritanceStateOfSuperEntity ( classDetails , inheritanceStatePerClass );
476481 if ( superEntityState != null ) {
477482 state .setHasParents ( true );
478483 if ( classType == EMBEDDABLE ) {
479- collector .registerEmbeddableSubclass ( superEntityState .getClassDetails (), clazz );
484+ collector .registerEmbeddableSubclass ( superEntityState .getClassDetails (), classDetails );
480485 }
481486 }
482- logMixedInheritance ( clazz , superclassState , state );
487+ logMixedInheritance ( classDetails , superclassState , state );
483488 if ( superclassState .getType () != null ) {
484489 state .setType ( superclassState .getType () );
485490 }
@@ -488,7 +493,7 @@ public static Map<ClassDetails, InheritanceState> buildInheritanceStates(
488493 case ENTITY :
489494 case MAPPED_SUPERCLASS :
490495 case EMBEDDABLE :
491- inheritanceStatePerClass .put ( clazz , state );
496+ inheritanceStatePerClass .put ( classDetails , state );
492497 }
493498 }
494499 return inheritanceStatePerClass ;
0 commit comments