Skip to content

Commit fb9d961

Browse files
committed
small fix
1 parent cb20f88 commit fb9d961

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.function.Supplier;
1313

1414
import org.hibernate.MappingException;
15+
import org.hibernate.boot.spi.BootstrapContext;
1516
import org.hibernate.boot.spi.MetadataBuildingContext;
1617
import org.hibernate.dialect.Dialect;
1718
import org.hibernate.mapping.BasicValue;
@@ -60,7 +61,8 @@ public static <T> BasicValue.Resolution<T> from(
6061
String propertyName,
6162
MetadataBuildingContext buildingContext) {
6263
final Dialect dialect = buildingContext.getMetadataCollector().getDatabase().getDialect();
63-
final TypeConfiguration typeConfiguration = buildingContext.getBootstrapContext().getTypeConfiguration();
64+
final BootstrapContext bootstrapContext = buildingContext.getBootstrapContext();
65+
final TypeConfiguration typeConfiguration = bootstrapContext.getTypeConfiguration();
6466

6567
final JavaType<T> reflectedJtd = reflectedJtdResolver.get();
6668

@@ -70,16 +72,15 @@ public static <T> BasicValue.Resolution<T> from(
7072

7173
final BasicType<T> jdbcMapping;
7274

73-
if ( explicitJavaType != null ) {
75+
if (explicitJavaType != null) {
7476
// we have an explicit JavaType
7577
if ( isTemporal( explicitJavaType ) ) {
7678
return fromTemporal(
7779
(TemporalJavaType<T>) explicitJavaType,
7880
null,
7981
explicitJdbcType,
8082
explicitMutabilityPlanAccess,
81-
stdIndicators,
82-
typeConfiguration
83+
stdIndicators
8384
);
8485
}
8586
else if ( explicitJdbcType != null ) {
@@ -116,7 +117,8 @@ else if ( reflectedJtd != null ) {
116117
return fromEnum(
117118
(EnumJavaType) reflectedJtd,
118119
null,
119-
stdIndicators
120+
stdIndicators,
121+
bootstrapContext
120122
);
121123
}
122124
else if ( isTemporal( reflectedJtd ) ) {
@@ -125,8 +127,7 @@ else if ( isTemporal( reflectedJtd ) ) {
125127
null,
126128
explicitJdbcType,
127129
explicitMutabilityPlanAccess,
128-
stdIndicators,
129-
typeConfiguration
130+
stdIndicators
130131
);
131132
}
132133
else if ( explicitJdbcType != null ) {
@@ -148,8 +149,8 @@ else if ( explicitJdbcType != null ) {
148149
final BasicValue.Resolution<?> resolution = fromEnum(
149150
(EnumJavaType<?>) elementJtd,
150151
null,
151-
stdIndicators
152-
);
152+
stdIndicators,
153+
bootstrapContext);
153154
registeredElementType = (BasicType<?>) resolution.getJdbcMapping();
154155
}
155156
else if ( isTemporal( elementJtd ) ) {
@@ -158,8 +159,7 @@ else if ( isTemporal( elementJtd ) ) {
158159
null,
159160
null,
160161
explicitMutabilityPlanAccess,
161-
stdIndicators,
162-
typeConfiguration
162+
stdIndicators
163163
);
164164
registeredElementType = resolution.getLegacyResolvedBasicType();
165165
}
@@ -305,17 +305,19 @@ public static <T> BasicType<T> resolveSqlTypeIndicators(
305305
public static <E extends Enum<E>> BasicValue.Resolution<E> fromEnum(
306306
EnumJavaType<E> enumJavaType,
307307
JdbcType explicitJdbcType,
308-
JdbcTypeIndicators stdIndicators) {
308+
JdbcTypeIndicators stdIndicators,
309+
BootstrapContext bootstrapContext) {
309310
final JdbcType jdbcType = explicitJdbcType == null
310-
? enumJavaType.getRecommendedJdbcType( stdIndicators )
311+
? enumJavaType.getRecommendedJdbcType(stdIndicators)
311312
: explicitJdbcType;
312-
final BasicType<E> jdbcMapping = new BasicTypeImpl<>( enumJavaType, jdbcType );
313+
final BasicTypeImpl<E> basicType = new BasicTypeImpl<>(enumJavaType, jdbcType);
314+
bootstrapContext.registerAdHocBasicType(basicType);
313315
return new InferredBasicValueResolution<>(
314-
jdbcMapping,
316+
basicType,
315317
enumJavaType,
316318
enumJavaType,
317319
jdbcType,
318-
jdbcMapping,
320+
basicType,
319321
ImmutableMutabilityPlan.instance()
320322
);
321323
}
@@ -325,15 +327,15 @@ public static <T> BasicValue.Resolution<T> fromTemporal(
325327
BasicJavaType<?> explicitJavaType,
326328
JdbcType explicitJdbcType,
327329
Function<TypeConfiguration, MutabilityPlan> explicitMutabilityPlanAccess,
328-
JdbcTypeIndicators stdIndicators,
329-
TypeConfiguration typeConfiguration) {
330+
JdbcTypeIndicators stdIndicators) {
331+
final TypeConfiguration typeConfiguration = stdIndicators.getTypeConfiguration();
330332
final TemporalType requestedTemporalPrecision = stdIndicators.getTemporalPrecision();
331333

332334
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333335
// Case #1 - explicit JavaType
334336

335-
if ( explicitJavaType != null ) {
336-
if ( !isTemporal( explicitJavaType ) ) {
337+
if (explicitJavaType != null) {
338+
if (!isTemporal(explicitJavaType)) {
337339
throw new MappingException(
338340
"Explicit JavaType [" + explicitJavaType +
339341
"] defined for temporal value must implement TemporalJavaType"
@@ -342,7 +344,6 @@ public static <T> BasicValue.Resolution<T> fromTemporal(
342344

343345
@SuppressWarnings("unchecked")
344346
final TemporalJavaType<T> explicitTemporalJtd = (TemporalJavaType<T>) explicitJavaType;
345-
346347
if ( requestedTemporalPrecision != null && explicitTemporalJtd.getPrecision() != requestedTemporalPrecision ) {
347348
throw new MappingException(
348349
"Temporal precision (`jakarta.persistence.TemporalType`) mismatch... requested precision = " + requestedTemporalPrecision +
@@ -354,9 +355,7 @@ public static <T> BasicValue.Resolution<T> fromTemporal(
354355
final JdbcType jdbcType = explicitJdbcType != null
355356
? explicitJdbcType
356357
: explicitTemporalJtd.getRecommendedJdbcType( stdIndicators );
357-
358358
final BasicType<T> jdbcMapping = typeConfiguration.getBasicTypeRegistry().resolve( explicitTemporalJtd, jdbcType );
359-
360359
final MutabilityPlan<T> mutabilityPlan = determineMutabilityPlan( explicitMutabilityPlanAccess, explicitTemporalJtd, typeConfiguration );
361360
return new InferredBasicValueResolution<>(
362361
jdbcMapping,

0 commit comments

Comments
 (0)