HHH-15823 Fallback to value type ignoring typeInferenceSource
This commit is contained in:
parent
ba1feef1f8
commit
3d72eabf6c
|
@ -1133,11 +1133,18 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
||||||
return new SqmLiteral<>( value, expressible, this );
|
return new SqmLiteral<>( value, expressible, this );
|
||||||
}
|
}
|
||||||
// Just like in HQL, we allow coercion of literal values to the inferred type
|
// Just like in HQL, we allow coercion of literal values to the inferred type
|
||||||
return new SqmLiteral<>(
|
T coercedValue = expressible.getExpressibleJavaType().coerce( value, this::getTypeConfiguration );
|
||||||
expressible.getExpressibleJavaType().coerce( value, this::getTypeConfiguration ),
|
if (expressible.getExpressibleJavaType().isInstance( coercedValue )) {
|
||||||
expressible,
|
return new SqmLiteral<>(
|
||||||
this
|
coercedValue,
|
||||||
);
|
expressible,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// ignore typeInferenceSource and fallback the value type
|
||||||
|
return literal( value );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> SqmExpressible<T> resolveInferredType(
|
private static <T> SqmExpressible<T> resolveInferredType(
|
||||||
|
@ -1700,11 +1707,22 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final SqmExpressible<T> expressible = bindableType.resolveExpressible( getTypeConfiguration().getSessionFactory() );
|
final SqmExpressible<T> expressible = bindableType.resolveExpressible( getTypeConfiguration().getSessionFactory() );
|
||||||
return new ValueBindJpaCriteriaParameter<>(
|
T coercedValue = expressible.getExpressibleJavaType().coerce( value, this::getTypeConfiguration );
|
||||||
bindableType,
|
if ( isInstance( bindableType, coercedValue ) ) {
|
||||||
expressible.getExpressibleJavaType().coerce( value, this::getTypeConfiguration ),
|
return new ValueBindJpaCriteriaParameter<>(
|
||||||
this
|
bindableType,
|
||||||
);
|
coercedValue,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// ignore typeInferenceSource and fallback the value type
|
||||||
|
return new ValueBindJpaCriteriaParameter<>(
|
||||||
|
queryEngine.getTypeConfiguration().getSessionFactory().resolveParameterBindType( value ),
|
||||||
|
value,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> boolean isInstance(BindableType<T> bindableType, T value) {
|
private <T> boolean isInstance(BindableType<T> bindableType, T value) {
|
||||||
|
|
Loading…
Reference in New Issue