44
44
import static org .hibernate .boot .model .internal .AnnotatedClassType .ENTITY ;
45
45
import static org .hibernate .boot .model .internal .EntityBinder .bindEntityClass ;
46
46
import static org .hibernate .boot .model .internal .FilterDefBinder .bindFilterDefs ;
47
+ import static org .hibernate .boot .model .internal .GeneratorBinder .registerGlobalGenerators ;
47
48
import static org .hibernate .boot .model .internal .GeneratorParameters .interpretSequenceGenerator ;
48
49
import static org .hibernate .boot .model .internal .GeneratorParameters .interpretTableGenerator ;
49
50
import static org .hibernate .boot .model .internal .InheritanceState .getInheritanceStateOfSuperEntity ;
50
51
import static org .hibernate .boot .model .internal .InheritanceState .getSuperclassInheritanceState ;
51
52
import 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 ;
52
57
import static org .hibernate .internal .util .StringHelper .unqualify ;
53
58
import static org .hibernate .mapping .MetadataSource .ANNOTATIONS ;
54
59
@@ -98,23 +103,23 @@ public static void bindDefaults(MetadataBuildingContext context) {
98
103
// result-set-mappings
99
104
100
105
globalRegistrations .getSqlResultSetMappingRegistrations ().forEach ( (name , mappingRegistration ) -> {
101
- QueryBinder . bindSqlResultSetMapping ( mappingRegistration .configuration (), context , true );
106
+ bindSqlResultSetMapping ( mappingRegistration .configuration (), context , true );
102
107
} );
103
108
104
109
105
110
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106
111
// queries
107
112
108
113
globalRegistrations .getNamedQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
109
- QueryBinder . bindQuery ( queryRegistration .configuration (), context , true , null );
114
+ bindQuery ( queryRegistration .configuration (), context , true , null );
110
115
} );
111
116
112
117
globalRegistrations .getNamedNativeQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
113
- QueryBinder . bindNativeQuery ( queryRegistration .configuration (), context , null , true );
118
+ bindNativeQuery ( queryRegistration .configuration (), context , null , true );
114
119
} );
115
120
116
121
globalRegistrations .getNamedStoredProcedureQueryRegistrations ().forEach ( (name , queryRegistration ) -> {
117
- QueryBinder . bindNamedStoredProcedureQuery ( queryRegistration .configuration (), context , true );
122
+ bindNamedStoredProcedureQuery ( queryRegistration .configuration (), context , true );
118
123
} );
119
124
120
125
}
@@ -130,7 +135,7 @@ public static void bindPackage(ClassLoaderService cls, String packageName, Metad
130
135
modelsContext ( context ).getClassDetailsRegistry ()
131
136
.resolveClassDetails ( pack .getName () + ".package-info" );
132
137
133
- GeneratorBinder . registerGlobalGenerators ( packageInfo , context );
138
+ registerGlobalGenerators ( packageInfo , context );
134
139
135
140
bindTypeDescriptorRegistrations ( packageInfo , context );
136
141
bindEmbeddableInstantiatorRegistrations ( packageInfo , context );
@@ -153,7 +158,7 @@ private static void bindNamedEntityGraphs(ClassDetails packageInfoClassDetails,
153
158
packageInfoClassDetails .forEachRepeatedAnnotationUsages (
154
159
HibernateAnnotations .NAMED_ENTITY_GRAPH ,
155
160
modelsContext ( context ),
156
- ( annotation ) -> collector .addNamedEntityGraph ( new NamedEntityGraphDefinition (
161
+ annotation -> collector .addNamedEntityGraph ( new NamedEntityGraphDefinition (
157
162
annotation .name (), null ,
158
163
NamedEntityGraphDefinition .Source .PARSED ,
159
164
new NamedGraphCreatorParsed ( annotation )
@@ -172,13 +177,13 @@ private static void bindNamedHibernateQueries(AnnotationTarget annotationTarget,
172
177
annotationTarget .forEachRepeatedAnnotationUsages (
173
178
HibernateAnnotations .NAMED_QUERY ,
174
179
sourceModelContext ,
175
- (usage ) -> QueryBinder . bindQuery ( usage , context , annotationTarget )
180
+ (usage ) -> bindQuery ( usage , context , annotationTarget )
176
181
);
177
182
178
183
annotationTarget .forEachRepeatedAnnotationUsages (
179
184
HibernateAnnotations .NAMED_NATIVE_QUERY ,
180
185
sourceModelContext ,
181
- (usage ) -> QueryBinder . bindNativeQuery ( usage , context , annotationTarget )
186
+ (usage ) -> bindNativeQuery ( usage , context , annotationTarget )
182
187
);
183
188
}
184
189
@@ -188,25 +193,25 @@ private static void bindNamedJpaQueries(AnnotationTarget annotationTarget, Metad
188
193
annotationTarget .forEachRepeatedAnnotationUsages (
189
194
JpaAnnotations .SQL_RESULT_SET_MAPPING ,
190
195
sourceModelContext ,
191
- (usage ) -> QueryBinder . bindSqlResultSetMapping ( usage , context ,false )
196
+ (usage ) -> bindSqlResultSetMapping ( usage , context ,false )
192
197
);
193
198
194
199
annotationTarget .forEachRepeatedAnnotationUsages (
195
200
JpaAnnotations .NAMED_QUERY ,
196
201
sourceModelContext ,
197
- (usage ) -> QueryBinder . bindQuery ( usage , context , false , annotationTarget )
202
+ (usage ) -> bindQuery ( usage , context , false , annotationTarget )
198
203
);
199
204
200
205
annotationTarget .forEachRepeatedAnnotationUsages (
201
206
JpaAnnotations .NAMED_NATIVE_QUERY ,
202
207
sourceModelContext ,
203
- (usage ) -> QueryBinder . bindNativeQuery ( usage , context , annotationTarget , false )
208
+ (usage ) -> bindNativeQuery ( usage , context , annotationTarget , false )
204
209
);
205
210
206
211
annotationTarget .forEachRepeatedAnnotationUsages (
207
212
JpaAnnotations .NAMED_STORED_PROCEDURE_QUERY ,
208
213
sourceModelContext ,
209
- (usage ) -> QueryBinder . bindNamedStoredProcedureQuery ( usage , context , false )
214
+ (usage ) -> bindNamedStoredProcedureQuery ( usage , context , false )
210
215
);
211
216
}
212
217
@@ -292,7 +297,7 @@ private static void handleJdbcTypeRegistration(
292
297
MetadataBuildingContext context ,
293
298
ManagedBeanRegistry managedBeanRegistry ,
294
299
JdbcTypeRegistration annotation ) {
295
- final JdbcType jdbcType = getBean ( context , managedBeanRegistry , annotation .value () );
300
+ final var jdbcType = getBean ( context , managedBeanRegistry , annotation .value () );
296
301
context .getMetadataCollector ()
297
302
.addJdbcTypeRegistration ( jdbcTypeCode ( annotation , jdbcType ), jdbcType );
298
303
}
@@ -417,9 +422,9 @@ private static void bindFetchProfile(FetchProfile fetchProfile, MetadataBuilding
417
422
final String name = fetchProfile .name ();
418
423
if ( reuseOrCreateFetchProfile ( context , name ) ) {
419
424
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 ) {
423
428
throw new AnnotationException (
424
429
"Fetch profile '" + name
425
430
+ "' has a '@FetchOverride' with 'fetch=LAZY' and 'mode=JOIN'"
@@ -461,25 +466,25 @@ public static Map<ClassDetails, InheritanceState> buildInheritanceStates(
461
466
MetadataBuildingContext buildingContext ) {
462
467
final Map <ClassDetails , InheritanceState > inheritanceStatePerClass = new HashMap <>( orderedClasses .size () );
463
468
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 ();
470
475
collector .addImport ( unqualify ( className ), className );
471
476
}
472
477
if ( superclassState != null ) {
473
478
//the classes are ordered thus preventing an NPE
474
479
superclassState .setHasSiblings ( true );
475
- final var superEntityState = getInheritanceStateOfSuperEntity ( clazz , inheritanceStatePerClass );
480
+ final var superEntityState = getInheritanceStateOfSuperEntity ( classDetails , inheritanceStatePerClass );
476
481
if ( superEntityState != null ) {
477
482
state .setHasParents ( true );
478
483
if ( classType == EMBEDDABLE ) {
479
- collector .registerEmbeddableSubclass ( superEntityState .getClassDetails (), clazz );
484
+ collector .registerEmbeddableSubclass ( superEntityState .getClassDetails (), classDetails );
480
485
}
481
486
}
482
- logMixedInheritance ( clazz , superclassState , state );
487
+ logMixedInheritance ( classDetails , superclassState , state );
483
488
if ( superclassState .getType () != null ) {
484
489
state .setType ( superclassState .getType () );
485
490
}
@@ -488,7 +493,7 @@ public static Map<ClassDetails, InheritanceState> buildInheritanceStates(
488
493
case ENTITY :
489
494
case MAPPED_SUPERCLASS :
490
495
case EMBEDDABLE :
491
- inheritanceStatePerClass .put ( clazz , state );
496
+ inheritanceStatePerClass .put ( classDetails , state );
492
497
}
493
498
}
494
499
return inheritanceStatePerClass ;
0 commit comments