12
12
import java .util .function .Supplier ;
13
13
14
14
import org .hibernate .MappingException ;
15
+ import org .hibernate .boot .spi .MetadataBuildingContext ;
15
16
import org .hibernate .dialect .Dialect ;
16
17
import org .hibernate .mapping .BasicValue ;
17
18
import org .hibernate .mapping .Column ;
20
21
import org .hibernate .tool .schema .extract .spi .ColumnTypeInformation ;
21
22
import org .hibernate .type .AdjustableBasicType ;
22
23
import org .hibernate .type .BasicType ;
23
- import org .hibernate .type .CustomType ;
24
24
import org .hibernate .type .SerializableType ;
25
25
import org .hibernate .type .descriptor .converter .internal .NamedEnumValueConverter ;
26
26
import org .hibernate .type .descriptor .converter .internal .OrdinalEnumValueConverter ;
27
27
import org .hibernate .type .descriptor .java .BasicJavaType ;
28
28
import org .hibernate .type .descriptor .java .BasicPluralJavaType ;
29
29
import org .hibernate .type .descriptor .java .EnumJavaType ;
30
- import org .hibernate .type .descriptor .java .ImmutableMutabilityPlan ;
31
30
import org .hibernate .type .descriptor .java .JavaType ;
32
31
import org .hibernate .type .descriptor .java .JavaTypeHelper ;
33
32
import org .hibernate .type .descriptor .java .MutabilityPlan ;
@@ -61,8 +60,10 @@ public static <T> BasicValue.Resolution<T> from(
61
60
Selectable selectable ,
62
61
String ownerName ,
63
62
String propertyName ,
64
- Dialect dialect ,
65
- TypeConfiguration typeConfiguration ) {
63
+ MetadataBuildingContext buildingContext ) {
64
+ final Dialect dialect = buildingContext .getMetadataCollector ().getDatabase ().getDialect ();
65
+ final TypeConfiguration typeConfiguration = buildingContext .getBootstrapContext ().getTypeConfiguration ();
66
+
66
67
final JavaType <T > reflectedJtd = reflectedJtdResolver .get ();
67
68
68
69
// NOTE : the distinction that is made below wrt `explicitJavaType` and `reflectedJtd` is
@@ -162,14 +163,14 @@ else if ( explicitJdbcType != null ) {
162
163
final JavaType <?> elementJtd = containerJtd .getElementJavaType ();
163
164
final BasicType registeredElementType ;
164
165
if ( elementJtd instanceof EnumJavaType ) {
165
- final EnumeratedValueResolution resolution = InferredBasicValueResolver .fromEnum (
166
- (EnumJavaType ) elementJtd ,
166
+ final EnumeratedValueResolution <?,?> resolution = InferredBasicValueResolver .fromEnum (
167
+ (EnumJavaType <?> ) elementJtd ,
167
168
null ,
168
169
null ,
169
170
stdIndicators ,
170
171
typeConfiguration
171
172
);
172
- registeredElementType = resolution .getLegacyResolvedBasicType ();
173
+ registeredElementType = resolution .getJdbcMapping ();
173
174
}
174
175
else if ( JavaTypeHelper .isTemporal ( elementJtd ) ) {
175
176
final InferredBasicValueResolution resolution = InferredBasicValueResolver .fromTemporal (
@@ -352,6 +353,11 @@ public static <E extends Enum<E>, R> EnumeratedValueResolution<E,R> fromEnum(
352
353
}
353
354
354
355
if ( enumStyle == null ) {
356
+ // NOTE : separate from the explicit ORDINAL check to facilitate
357
+ // handling native database enum types. In theory anyway - atm
358
+ // we cannot discern an implicit (default value) or explicit style
359
+ // due to HCANN and annotation handling for default values
360
+
355
361
//noinspection unchecked
356
362
return (EnumeratedValueResolution <E , R >) ordinalEnumValueResolution (
357
363
enumJavaType ,
@@ -375,8 +381,6 @@ private static <E extends Enum<E>, N extends Number> EnumeratedValueResolution<E
375
381
final JdbcType jdbcType = ordinalJdbcType ( explicitJdbcType , enumJavaType , typeConfiguration );
376
382
377
383
return new EnumeratedValueResolution <>(
378
- enumJavaType ,
379
- relationalJavaType ,
380
384
jdbcType ,
381
385
new OrdinalEnumValueConverter <>( enumJavaType , jdbcType , relationalJavaType ),
382
386
typeConfiguration
@@ -405,29 +409,6 @@ private static <N extends Number> JavaType<N> ordinalJavaType(JavaType<N> explic
405
409
}
406
410
}
407
411
408
- private static <E extends Enum <E >, N extends Number > InferredBasicValueResolution <E , N > ordinalResolution (
409
- EnumJavaType <E > enumJavaType ,
410
- JavaType <N > relationalJtd ,
411
- JdbcType jdbcType ,
412
- TypeConfiguration typeConfiguration ) {
413
- final CustomType <E > customType = new CustomType <>(
414
- new org .hibernate .type .EnumType <>(
415
- enumJavaType .getJavaTypeClass (),
416
- new OrdinalEnumValueConverter <>( enumJavaType , jdbcType , relationalJtd ),
417
- typeConfiguration
418
- ),
419
- typeConfiguration
420
- );
421
- return new InferredBasicValueResolution <>(
422
- customType ,
423
- enumJavaType ,
424
- relationalJtd ,
425
- jdbcType ,
426
- customType ,
427
- ImmutableMutabilityPlan .instance ()
428
- );
429
- }
430
-
431
412
private static <E extends Enum <E >> EnumeratedValueResolution <E ,String > stringEnumValueResolution (
432
413
EnumJavaType <E > enumJavaType ,
433
414
BasicJavaType <?> explicitJavaType ,
@@ -438,8 +419,6 @@ private static <E extends Enum<E>> EnumeratedValueResolution<E,String> stringEnu
438
419
final JdbcType jdbcType = stringJdbcType ( explicitJdbcType , stdIndicators , relationalJtd );
439
420
440
421
return new EnumeratedValueResolution <>(
441
- enumJavaType ,
442
- relationalJtd ,
443
422
jdbcType ,
444
423
new NamedEnumValueConverter <>( enumJavaType , jdbcType , relationalJtd ),
445
424
typeConfiguration
0 commit comments