51
51
import org .hibernate .boot .model .source .internal .hbm .ModelBinder ;
52
52
import org .hibernate .boot .model .source .spi .MetadataSourceProcessor ;
53
53
import org .hibernate .boot .models .internal .DomainModelCategorizationCollector ;
54
- import org .hibernate .boot .models .internal .OrmAnnotationHelper ;
55
54
import org .hibernate .boot .models .xml .spi .XmlPreProcessingResult ;
56
55
import org .hibernate .boot .models .xml .spi .XmlPreProcessor ;
57
56
import org .hibernate .boot .models .xml .spi .XmlProcessingResult ;
73
72
import org .hibernate .engine .config .spi .StandardConverters ;
74
73
import org .hibernate .engine .jdbc .spi .JdbcServices ;
75
74
import org .hibernate .mapping .Table ;
76
- import org .hibernate .models .internal .jandex .JandexClassDetails ;
77
75
import org .hibernate .models .internal .jandex .JandexIndexerHelper ;
78
- import org .hibernate .models .internal .jdk .JdkBuilders ;
79
- import org .hibernate .models .spi .AnnotationDescriptorRegistry ;
80
76
import org .hibernate .models .spi .ClassDetails ;
81
77
import org .hibernate .models .spi .ClassDetailsRegistry ;
82
78
import org .hibernate .models .spi .ClassLoading ;
83
- import org .hibernate .models .spi .RegistryPrimer ;
84
79
import org .hibernate .models .spi .SourceModelBuildingContext ;
85
80
import org .hibernate .type .BasicType ;
86
81
import org .hibernate .type .BasicTypeRegistry ;
101
96
import org .hibernate .type .spi .TypeConfiguration ;
102
97
import org .hibernate .usertype .CompositeUserType ;
103
98
104
- import org .jboss .jandex .ClassInfo ;
105
99
import org .jboss .jandex .CompositeIndex ;
106
100
import org .jboss .jandex .IndexView ;
107
101
import org .jboss .jandex .Indexer ;
108
- import org .jboss .logging .Logger ;
109
102
110
103
import jakarta .persistence .AttributeConverter ;
111
104
135
128
* @author Steve Ebersole
136
129
*/
137
130
public class MetadataBuildingProcess {
138
- private static final Logger log = Logger .getLogger ( MetadataBuildingProcess .class );
139
131
140
132
/**
141
133
* Unified single phase for MetadataSources to Metadata process
@@ -221,16 +213,14 @@ public static MetadataImplementor complete(
221
213
// Set up the processors and start binding
222
214
// NOTE : this becomes even more simplified after we move purely
223
215
// to unified model
224
- final IndexView jandexView = domainModelSource .getJandexIndex ();
216
+ // final IndexView jandexView = domainModelSource.getJandexIndex();
225
217
226
218
coordinateProcessors (
227
219
managedResources ,
228
220
options ,
229
221
rootMetadataBuildingContext ,
230
222
domainModelSource ,
231
- classLoaderService ,
232
- metadataCollector ,
233
- jandexView
223
+ metadataCollector
234
224
);
235
225
236
226
processAdditionalMappingContributions ( metadataCollector , options , classLoaderService , rootMetadataBuildingContext );
@@ -245,19 +235,18 @@ private static void coordinateProcessors(
245
235
MetadataBuildingOptions options ,
246
236
MetadataBuildingContextRootImpl rootMetadataBuildingContext ,
247
237
DomainModelSource domainModelSource ,
248
- ClassLoaderService classLoaderService ,
249
- InFlightMetadataCollectorImpl metadataCollector ,
250
- IndexView jandexView ) {
238
+ InFlightMetadataCollectorImpl metadataCollector ) {
251
239
final MetadataSourceProcessor processor = new MetadataSourceProcessor () {
252
240
private final MetadataSourceProcessor hbmProcessor = options .isXmlMappingEnabled ()
253
241
? new HbmMetadataSourceProcessorImpl ( managedResources , rootMetadataBuildingContext )
254
242
: new NoOpMetadataSourceProcessorImpl ();
255
243
256
- private final AnnotationMetadataSourceProcessorImpl annotationProcessor = new AnnotationMetadataSourceProcessorImpl (
257
- managedResources ,
258
- domainModelSource ,
259
- rootMetadataBuildingContext
260
- );
244
+ private final AnnotationMetadataSourceProcessorImpl annotationProcessor =
245
+ new AnnotationMetadataSourceProcessorImpl (
246
+ managedResources ,
247
+ domainModelSource ,
248
+ rootMetadataBuildingContext
249
+ );
261
250
262
251
@ Override
263
252
public void prepare () {
@@ -527,66 +516,51 @@ public static IndexView resolveJandexIndex(
527
516
528
517
return CompositeIndex .create ( suppliedJandexIndex , jandexIndexer .complete () );
529
518
}
530
-
531
- public static void preFillRegistries (RegistryPrimer .Contributions contributions , SourceModelBuildingContext buildingContext ) {
532
- OrmAnnotationHelper .forEachOrmAnnotation ( contributions ::registerAnnotation );
533
-
534
- final IndexView jandexIndex = buildingContext .getJandexIndex ();
535
- if ( jandexIndex == null ) {
536
- return ;
537
- }
538
-
539
- final ClassDetailsRegistry classDetailsRegistry = buildingContext .getClassDetailsRegistry ();
540
- final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext .getAnnotationDescriptorRegistry ();
541
-
542
- for ( ClassInfo knownClass : jandexIndex .getKnownClasses () ) {
543
- final String className = knownClass .name ().toString ();
544
-
545
- if ( knownClass .isAnnotation () ) {
546
- // it is always safe to load the annotation classes - we will never be enhancing them
547
- //noinspection rawtypes
548
- final Class annotationClass = buildingContext
549
- .getClassLoading ()
550
- .classForName ( className );
551
- //noinspection unchecked
552
- annotationDescriptorRegistry .resolveDescriptor (
553
- annotationClass ,
554
- (t ) -> JdkBuilders .buildAnnotationDescriptor ( annotationClass , buildingContext )
555
- );
556
- }
557
-
558
- classDetailsRegistry .resolveClassDetails (
559
- className ,
560
- (name ) -> new JandexClassDetails ( knownClass , buildingContext )
561
- );
562
- }
563
- }
519
+ //
520
+ // public static void preFillRegistries(RegistryPrimer.Contributions contributions, SourceModelBuildingContext buildingContext) {
521
+ // OrmAnnotationHelper.forEachOrmAnnotation( contributions::registerAnnotation );
522
+ //
523
+ // final IndexView jandexIndex = buildingContext.getJandexIndex();
524
+ // if ( jandexIndex == null ) {
525
+ // return;
526
+ // }
527
+ //
528
+ // final ClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry();
529
+ // final AnnotationDescriptorRegistry annotationDescriptorRegistry = buildingContext.getAnnotationDescriptorRegistry();
530
+ //
531
+ // for ( ClassInfo knownClass : jandexIndex.getKnownClasses() ) {
532
+ // final String className = knownClass.name().toString();
533
+ //
534
+ // if ( knownClass.isAnnotation() ) {
535
+ // // it is always safe to load the annotation classes - we will never be enhancing them
536
+ // //noinspection rawtypes
537
+ // final Class annotationClass = buildingContext
538
+ // .getClassLoading()
539
+ // .classForName( className );
540
+ // //noinspection unchecked
541
+ // annotationDescriptorRegistry.resolveDescriptor(
542
+ // annotationClass,
543
+ // (t) -> JdkBuilders.buildAnnotationDescriptor( annotationClass, buildingContext )
544
+ // );
545
+ // }
546
+ //
547
+ // classDetailsRegistry.resolveClassDetails(
548
+ // className,
549
+ // (name) -> new JandexClassDetails( knownClass, buildingContext )
550
+ // );
551
+ // }
552
+ // }
564
553
565
554
private static void processAdditionalMappingContributions (
566
555
InFlightMetadataCollectorImpl metadataCollector ,
567
556
MetadataBuildingOptions options ,
568
557
ClassLoaderService classLoaderService ,
569
558
MetadataBuildingContextRootImpl rootMetadataBuildingContext ) {
570
- final MappingBinder mappingBinder ;
571
- if ( options .isXmlMappingEnabled () ) {
572
- mappingBinder = new MappingBinder (
573
- classLoaderService ,
574
- new MappingBinder .Options () {
575
- @ Override
576
- public boolean validateMappings () {
577
- return false ;
578
- }
579
- }
580
- );
581
- }
582
- else {
583
- mappingBinder = null ;
584
- }
585
559
586
560
final AdditionalMappingContributionsImpl contributions = new AdditionalMappingContributionsImpl (
587
561
metadataCollector ,
588
562
options ,
589
- mappingBinder ,
563
+ options . isXmlMappingEnabled () ? new MappingBinder ( classLoaderService , () -> false ) : null ,
590
564
rootMetadataBuildingContext
591
565
);
592
566
@@ -1016,29 +990,27 @@ private static void adaptTimestampTypesToDefaultTimeZoneStorage(
1016
990
}
1017
991
1018
992
private static JdbcType getTimeWithTimeZoneOverride (MetadataBuildingOptions options , JdbcTypeRegistry jdbcTypeRegistry ) {
1019
- switch ( options .getDefaultTimeZoneStorage () ) {
1020
- case NORMALIZE :
993
+ return switch ( options .getDefaultTimeZoneStorage () ) {
994
+ case NORMALIZE ->
1021
995
// For NORMALIZE, we replace the standard types that use TIME_WITH_TIMEZONE to use TIME
1022
- return jdbcTypeRegistry .getDescriptor ( Types .TIME );
1023
- case NORMALIZE_UTC :
996
+ jdbcTypeRegistry .getDescriptor ( Types .TIME );
997
+ case NORMALIZE_UTC ->
1024
998
// For NORMALIZE_UTC, we replace the standard types that use TIME_WITH_TIMEZONE to use TIME_UTC
1025
- return jdbcTypeRegistry .getDescriptor ( SqlTypes .TIME_UTC );
1026
- default :
1027
- return null ;
1028
- }
999
+ jdbcTypeRegistry .getDescriptor ( SqlTypes .TIME_UTC );
1000
+ default -> null ;
1001
+ };
1029
1002
}
1030
1003
1031
1004
private static JdbcType getTimestampWithTimeZoneOverride (MetadataBuildingOptions options , JdbcTypeRegistry jdbcTypeRegistry ) {
1032
- switch ( options .getDefaultTimeZoneStorage () ) {
1033
- case NORMALIZE :
1005
+ return switch (options .getDefaultTimeZoneStorage ()) {
1006
+ case NORMALIZE ->
1034
1007
// For NORMALIZE, we replace the standard types that use TIMESTAMP_WITH_TIMEZONE to use TIMESTAMP
1035
- return jdbcTypeRegistry .getDescriptor ( Types .TIMESTAMP );
1036
- case NORMALIZE_UTC :
1008
+ jdbcTypeRegistry .getDescriptor ( Types .TIMESTAMP );
1009
+ case NORMALIZE_UTC ->
1037
1010
// For NORMALIZE_UTC, we replace the standard types that use TIMESTAMP_WITH_TIMEZONE to use TIMESTAMP_UTC
1038
- return jdbcTypeRegistry .getDescriptor ( SqlTypes .TIMESTAMP_UTC );
1039
- default :
1040
- return null ;
1041
- }
1011
+ jdbcTypeRegistry .getDescriptor ( SqlTypes .TIMESTAMP_UTC );
1012
+ default -> null ;
1013
+ };
1042
1014
}
1043
1015
1044
1016
private static void addFallbackIfNecessary (
0 commit comments