hibernate/hibernate-orm · error · IllegalArgumentException
Unsure how to handle given Java type [{}] as TemporalType#DA
Error message
Unsure how to handle given Java type [{}] as TemporalType#DATE What it means
When a parameter is bound with TemporalType.DATE, BindingTypeHelper.resolveDateTemporalTypeVariant maps the parameter's Java type to a DATE basic type (BindingTypeHelper.java:151-174). It accepts the assignable base type, Calendar, java.util.Date, LocalDate, Instant, OffsetDateTime and ZonedDateTime; any other class falls through to this IllegalArgumentException naming the unsupported Java type.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/type/internal/BindingTypeHelper.java:171
return baseType;
}
else if ( Calendar.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.CALENDAR_DATE );
}
else if ( java.util.Date.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.DATE );
}
else if ( Instant.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.INSTANT );
}
else if ( OffsetDateTime.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.OFFSET_DATE_TIME );
}
else if ( ZonedDateTime.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.ZONED_DATE_TIME );
}
else {
throw new IllegalArgumentException( "Unsure how to handle given Java type ["
+ javaType.getName() + "] as TemporalType#DATE" );
}
}
private static BindableType<?> resolveTimeTemporalTypeVariant(
Class<?> javaType,
BindableType<?> baseType,
TypeConfiguration typeConfiguration) {
if ( Calendar.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.CALENDAR_TIME );
}
else if ( java.util.Date.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.TIME );
}
else if ( LocalTime.class.isAssignableFrom( javaType ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.LOCAL_TIME );
}
else if ( OffsetTime.class.isAssignableFrom( javaType ) ) {View on GitHub (pinned to fad1729dce)
Solutions
- Remove the TemporalType argument and let Hibernate derive precision from the mapped attribute/parameter type.
- Use TemporalType.TIME for LocalTime/OffsetTime and TemporalType.TIMESTAMP for LocalDateTime, or convert the value to LocalDate before binding with DATE precision.
- For custom temporal classes, bind a standard type (LocalDate) converted from your class.
Example fix
// before - LocalTime cannot be bound as DATE
query.setParameter("d", LocalTime.now(), TemporalType.DATE);
// after - correct precision for the type
query.setParameter("t", LocalTime.now(), TemporalType.TIME);
// or simply
query.setParameter("t", LocalTime.now()); Defensive patterns
Strategy: type-guard
Validate before calling
static final Set<Class<?>> DATE_OK = Set.of(
java.util.Date.class, java.util.Calendar.class, java.time.LocalDate.class,
java.time.Instant.class, java.time.OffsetDateTime.class, java.time.ZonedDateTime.class );
if ( !DATE_OK.contains( value.getClass() ) ) {
throw new IllegalArgumentException( "Type " + value.getClass().getSimpleName()
+ " cannot be bound with TemporalType.DATE" );
} Type guard
static boolean supportsDatePrecision(Object v) {
return v instanceof java.util.Date || v instanceof java.util.Calendar
|| v instanceof java.time.LocalDate || v instanceof java.time.Instant
|| v instanceof java.time.OffsetDateTime || v instanceof java.time.ZonedDateTime;
} Prevention
- Do not reuse TemporalType.DATE for LocalTime/LocalDateTime parameters.
- When converting fields from Date to java.time types, audit every setParameter call with a TemporalType argument.
- Write a unit test matrix of (value type x TemporalType) against your binding helper.
When it happens
Trigger: Query.setParameter('d', LocalTime.now(), TemporalType.DATE) or LocalDateTime with DATE precision - neither is a DATE-only type in the handled set; binding custom date-like classes with TemporalType.DATE.
Common situations: Reusing a TemporalType.DATE argument on time-carrying types after a field changed from Date to LocalTime/LocalDateTime; copy-pasted stored-procedure binding code applied to parameters of the wrong temporal kind.
Related errors
- Cannot treat non-temporal parameter type with temporal preci
- Unsure how to handle given Java type [{}] as TemporalType#TI
- Unsure how to handle given Java type [{}] as TemporalType#TI
- The parameter [{param}] is not part of this Query
- Unable to determine JDBC type for converted parameter relati
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/1f777794820806b6.
Report an issue: GitHub.