hibernate/hibernate-orm · error · IllegalArgumentException
Unsure how to handle given Java type [{}] as TemporalType#TI
Error message
Unsure how to handle given Java type [{}] as TemporalType#TIME What it means
When a parameter is bound with TemporalType.TIME, BindingTypeHelper.resolveTimeTemporalTypeVariant maps the parameter's Java type to a TIME basic type (BindingTypeHelper.java:177-196). Only Calendar, java.util.Date, LocalTime and OffsetTime are handled; every 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:193
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 ) ) {
return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.OFFSET_TIME );
}
else {
throw new IllegalArgumentException( "Unsure how to handle given Java type ["
+ javaType.getName() + "] as TemporalType#TIME" );
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Drop the TemporalType argument - LocalTime/OffsetTime map correctly without it.
- Use TemporalType.DATE for LocalDate and TemporalType.TIMESTAMP for LocalDateTime, or convert: value.toLocalTime() before binding with TIME precision.
- For plain java.util.Date/Calendar values, TemporalType.TIME works as-is - keep those types if you need explicit precision.
Example fix
// before - LocalDateTime cannot be bound as TIME
query.setParameter("t", LocalDateTime.now(), TemporalType.TIME);
// after - convert to the time part
query.setParameter("t", LocalDateTime.now().toLocalTime()); Defensive patterns
Strategy: type-guard
Validate before calling
static final Set<Class<?>> TIME_OK = Set.of(
java.util.Calendar.class, java.util.Date.class,
java.time.LocalTime.class, java.time.OffsetTime.class );
if ( !TIME_OK.contains( value.getClass() ) ) {
throw new IllegalArgumentException( "Type " + value.getClass().getSimpleName()
+ " cannot be bound with TemporalType.TIME" );
} Type guard
static boolean supportsTimePrecision(Object v) {
return v instanceof java.util.Calendar || v instanceof java.util.Date
|| v instanceof java.time.LocalTime || v instanceof java.time.OffsetTime;
} Prevention
- Reserve TemporalType.TIME for LocalTime/OffsetTime/Date/Calendar values.
- Convert LocalDateTime parameters with toLocalTime() when TIME precision is required.
- Default to the no-precision setParameter overload and only add TemporalType when the stored column demands it.
When it happens
Trigger: Query.setParameter('t', LocalDateTime.now(), TemporalType.TIME) or LocalDate with TIME precision; binding any date-only or timestamp type with TemporalType.TIME.
Common situations: Parameters copied from a date/timestamp context into a time slot; legacy java.util.Date parameters migrated to LocalDateTime while the TemporalType.TIME argument remained.
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#DA
- 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/082259e341392bbc.
Report an issue: GitHub.