@@ -41,21 +41,27 @@ public <T> BindableType<T> resolveTemporalPrecision(
41
41
BindableType <T > declaredParameterType ,
42
42
SessionFactoryImplementor sessionFactory ) {
43
43
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 ;
49
56
}
50
57
51
- final TemporalJavaType <T > temporalJtd = (TemporalJavaType <T >) sqmExpressible .getExpressibleJavaType ();
52
- if ( temporalJtd .getPrecision () != precision ) {
58
+ if ( temporalJtd == null || temporalJtd .getPrecision () != precision ) {
53
59
final TypeConfiguration typeConfiguration = sessionFactory .getTypeConfiguration ();
54
60
final TemporalJavaType <T > temporalTypeForPrecision ;
55
61
// Special case java.util.Date, because TemporalJavaType#resolveTypeForPrecision doesn't support widening,
56
62
// since the main purpose of that method is to determine the final java type based on the reflective type
57
63
// + 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 () ) ) {
59
65
//noinspection unchecked
60
66
temporalTypeForPrecision = (TemporalJavaType <T >) typeConfiguration .getJavaTypeRegistry ().getDescriptor (
61
67
TemporalJavaType .resolveJavaTypeClass ( precision )
0 commit comments