@@ -41,21 +41,27 @@ public <T> BindableType<T> resolveTemporalPrecision(
4141 BindableType <T > declaredParameterType ,
4242 SessionFactoryImplementor sessionFactory ) {
4343 if ( precision != null ) {
44- final SqmExpressible <T > sqmExpressible = declaredParameterType .resolveExpressible ( sessionFactory );
45- if ( !( JavaTypeHelper .isTemporal ( sqmExpressible .getExpressibleJavaType () ) ) ) {
46- throw new UnsupportedOperationException (
47- "Cannot treat non-temporal parameter type with temporal precision"
48- );
44+ final TemporalJavaType <T > temporalJtd ;
45+ if ( declaredParameterType != null ) {
46+ final SqmExpressible <T > sqmExpressible = declaredParameterType .resolveExpressible ( sessionFactory );
47+ if ( !( JavaTypeHelper .isTemporal ( sqmExpressible .getExpressibleJavaType () ) ) ) {
48+ throw new UnsupportedOperationException (
49+ "Cannot treat non-temporal parameter type with temporal precision"
50+ );
51+ }
52+ temporalJtd = (TemporalJavaType <T >) sqmExpressible .getExpressibleJavaType ();
53+ }
54+ else {
55+ temporalJtd = null ;
4956 }
5057
51- final TemporalJavaType <T > temporalJtd = (TemporalJavaType <T >) sqmExpressible .getExpressibleJavaType ();
52- if ( temporalJtd .getPrecision () != precision ) {
58+ if ( temporalJtd == null || temporalJtd .getPrecision () != precision ) {
5359 final TypeConfiguration typeConfiguration = sessionFactory .getTypeConfiguration ();
5460 final TemporalJavaType <T > temporalTypeForPrecision ;
5561 // Special case java.util.Date, because TemporalJavaType#resolveTypeForPrecision doesn't support widening,
5662 // since the main purpose of that method is to determine the final java type based on the reflective type
5763 // + the explicit @Temporal(TemporalType...) configuration
58- if ( java .util .Date .class .isAssignableFrom ( temporalJtd .getJavaTypeClass () ) ) {
64+ if ( temporalJtd == null || java .util .Date .class .isAssignableFrom ( temporalJtd .getJavaTypeClass () ) ) {
5965 //noinspection unchecked
6066 temporalTypeForPrecision = (TemporalJavaType <T >) typeConfiguration .getJavaTypeRegistry ().getDescriptor (
6167 TemporalJavaType .resolveJavaTypeClass ( precision )
0 commit comments