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
100105globalRegistrations .getSqlResultSetMappingRegistrations ().forEach ( (name , mappingRegistration ) -> {
101- QueryBinder . bindSqlResultSetMapping ( mappingRegistration .configuration (), context , true );
106+ bindSqlResultSetMapping ( mappingRegistration .configuration (), context , true );
102107} );
103108
104109
105110// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106111// queries
107112
108113globalRegistrations .getNamedQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
109- QueryBinder . bindQuery ( queryRegistration .configuration (), context , true , null );
114+ bindQuery ( queryRegistration .configuration (), context , true , null );
110115} );
111116
112117globalRegistrations .getNamedNativeQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
113- QueryBinder . bindNativeQuery ( queryRegistration .configuration (), context , null , true );
118+ bindNativeQuery ( queryRegistration .configuration (), context , null , true );
114119} );
115120
116121globalRegistrations .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
130135modelsContext ( context ).getClassDetailsRegistry ()
131136.resolveClassDetails ( pack .getName () + ".package-info" );
132137
133- GeneratorBinder . registerGlobalGenerators ( packageInfo , context );
138+ registerGlobalGenerators ( packageInfo , context );
134139
135140bindTypeDescriptorRegistrations ( packageInfo , context );
136141bindEmbeddableInstantiatorRegistrations ( packageInfo , context );
@@ -153,7 +158,7 @@ private static void bindNamedEntityGraphs(ClassDetails packageInfoClassDetails,
153158packageInfoClassDetails .forEachRepeatedAnnotationUsages (
154159HibernateAnnotations .NAMED_ENTITY_GRAPH ,
155160modelsContext ( context ),
156- ( annotation ) -> collector .addNamedEntityGraph ( new NamedEntityGraphDefinition (
161+ annotation -> collector .addNamedEntityGraph ( new NamedEntityGraphDefinition (
157162annotation .name (), null ,
158163NamedEntityGraphDefinition .Source .PARSED ,
159164new NamedGraphCreatorParsed ( annotation )
@@ -172,13 +177,13 @@ private static void bindNamedHibernateQueries(AnnotationTarget annotationTarget,
172177annotationTarget .forEachRepeatedAnnotationUsages (
173178HibernateAnnotations .NAMED_QUERY ,
174179sourceModelContext ,
175- (usage ) -> QueryBinder . bindQuery ( usage , context , annotationTarget )
180+ (usage ) -> bindQuery ( usage , context , annotationTarget )
176181);
177182
178183annotationTarget .forEachRepeatedAnnotationUsages (
179184HibernateAnnotations .NAMED_NATIVE_QUERY ,
180185sourceModelContext ,
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
188193annotationTarget .forEachRepeatedAnnotationUsages (
189194JpaAnnotations .SQL_RESULT_SET_MAPPING ,
190195sourceModelContext ,
191- (usage ) -> QueryBinder . bindSqlResultSetMapping ( usage , context ,false )
196+ (usage ) -> bindSqlResultSetMapping ( usage , context ,false )
192197);
193198
194199annotationTarget .forEachRepeatedAnnotationUsages (
195200JpaAnnotations .NAMED_QUERY ,
196201sourceModelContext ,
197- (usage ) -> QueryBinder . bindQuery ( usage , context , false , annotationTarget )
202+ (usage ) -> bindQuery ( usage , context , false , annotationTarget )
198203);
199204
200205annotationTarget .forEachRepeatedAnnotationUsages (
201206JpaAnnotations .NAMED_NATIVE_QUERY ,
202207sourceModelContext ,
203- (usage ) -> QueryBinder . bindNativeQuery ( usage , context , annotationTarget , false )
208+ (usage ) -> bindNativeQuery ( usage , context , annotationTarget , false )
204209);
205210
206211annotationTarget .forEachRepeatedAnnotationUsages (
207212JpaAnnotations .NAMED_STORED_PROCEDURE_QUERY ,
208213sourceModelContext ,
209- (usage ) -> QueryBinder . bindNamedStoredProcedureQuery ( usage , context , false )
214+ (usage ) -> bindNamedStoredProcedureQuery ( usage , context , false )
210215);
211216}
212217
@@ -292,7 +297,7 @@ private static void handleJdbcTypeRegistration(
292297MetadataBuildingContext context ,
293298ManagedBeanRegistry managedBeanRegistry ,
294299JdbcTypeRegistration annotation ) {
295- final JdbcType jdbcType = getBean ( context , managedBeanRegistry , annotation .value () );
300+ final var jdbcType = getBean ( context , managedBeanRegistry , annotation .value () );
296301context .getMetadataCollector ()
297302.addJdbcTypeRegistration ( jdbcTypeCode ( annotation , jdbcType ), jdbcType );
298303}
@@ -417,9 +422,9 @@ private static void bindFetchProfile(FetchProfile fetchProfile, MetadataBuilding
417422final String name = fetchProfile .name ();
418423if ( reuseOrCreateFetchProfile ( context , name ) ) {
419424for ( 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 ) {
423428throw 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(
461466MetadataBuildingContext buildingContext ) {
462467final Map <ClassDetails , InheritanceState > inheritanceStatePerClass = new HashMap <>( orderedClasses .size () );
463468final 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 ();
470475collector .addImport ( unqualify ( className ), className );
471476}
472477if ( superclassState != null ) {
473478//the classes are ordered thus preventing an NPE
474479superclassState .setHasSiblings ( true );
475- final var superEntityState = getInheritanceStateOfSuperEntity ( clazz , inheritanceStatePerClass );
480+ final var superEntityState = getInheritanceStateOfSuperEntity ( classDetails , inheritanceStatePerClass );
476481if ( superEntityState != null ) {
477482state .setHasParents ( true );
478483if ( 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 );
483488if ( superclassState .getType () != null ) {
484489state .setType ( superclassState .getType () );
485490}
@@ -488,7 +493,7 @@ public static Map<ClassDetails, InheritanceState> buildInheritanceStates(
488493case ENTITY :
489494case MAPPED_SUPERCLASS :
490495case EMBEDDABLE :
491- inheritanceStatePerClass .put ( clazz , state );
496+ inheritanceStatePerClass .put ( classDetails , state );
492497}
493498}
494499return inheritanceStatePerClass ;
0 commit comments