@@ -39,21 +39,27 @@ public <T> BindableType<T> resolveTemporalPrecision(
3939 BindableType <T > declaredParameterType ,
4040 BindingContext bindingContext ) {
4141 if ( precision != null ) {
42- final SqmExpressible <T > sqmExpressible = declaredParameterType .resolveExpressible (bindingContext );
43- if ( !( JavaTypeHelper .isTemporal ( sqmExpressible .getExpressibleJavaType () ) ) ) {
44- throw new UnsupportedOperationException (
45- "Cannot treat non-temporal parameter type with temporal precision"
46- );
42+ final TemporalJavaType <T > temporalJtd ;
43+ if ( declaredParameterType != null ) {
44+ final SqmExpressible <T > sqmExpressible = declaredParameterType .resolveExpressible ( bindingContext );
45+ if ( !( JavaTypeHelper .isTemporal ( sqmExpressible .getExpressibleJavaType () ) ) ) {
46+ throw new UnsupportedOperationException (
47+ "Cannot treat non-temporal parameter type with temporal precision"
48+ );
49+ }
50+ temporalJtd = (TemporalJavaType <T >) sqmExpressible .getExpressibleJavaType ();
51+ }
52+ else {
53+ temporalJtd = null ;
4754 }
4855
49- final TemporalJavaType <T > temporalJtd = (TemporalJavaType <T >) sqmExpressible .getExpressibleJavaType ();
50- if ( temporalJtd .getPrecision () != precision ) {
56+ if ( temporalJtd == null || temporalJtd .getPrecision () != precision ) {
5157 final TypeConfiguration typeConfiguration = bindingContext .getTypeConfiguration ();
5258 final TemporalJavaType <T > temporalTypeForPrecision ;
5359 // Special case java.util.Date, because TemporalJavaType#resolveTypeForPrecision doesn't support widening,
5460 // since the main purpose of that method is to determine the final java type based on the reflective type
5561 // + the explicit @Temporal(TemporalType...) configuration
56- if ( java .util .Date .class .isAssignableFrom ( temporalJtd .getJavaTypeClass () ) ) {
62+ if ( temporalJtd == null || java .util .Date .class .isAssignableFrom ( temporalJtd .getJavaTypeClass () ) ) {
5763 //noinspection unchecked
5864 temporalTypeForPrecision = (TemporalJavaType <T >) typeConfiguration .getJavaTypeRegistry ().getDescriptor (
5965 TemporalJavaType .resolveJavaTypeClass ( precision )
0 commit comments