hibernate/hibernate-orm · error · UnsupportedOperationException
getTypeName() + " as TemporalType.TIME not supported"
Error message
getTypeName() + " as TemporalType.TIME not supported"
What it means
The TIME-precision variant: AbstractTemporalJavaType.resolveTypeForPrecision(TemporalType.TIME, ...) delegates to forTimePrecision, whose default throws UnsupportedOperationException for descriptors with no time-of-day representation (LocalDate, LocalDateTime, OffsetDateTime, JdbcDateJavaType, JdbcTimestampJavaType's default, etc.).
Source
Thrown at hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractTemporalJavaType.java:68
private TemporalJavaType<T> forMissingPrecision(TypeConfiguration typeConfiguration) {
return this;
}
protected TemporalJavaType<T> forTimestampPrecision(TypeConfiguration typeConfiguration) {
throw new UnsupportedOperationException(
getTypeName() + " as TemporalType.TIMESTAMP not supported"
);
}
protected TemporalJavaType<T> forDatePrecision(TypeConfiguration typeConfiguration) {
throw new UnsupportedOperationException(
getTypeName() + " as TemporalType.DATE not supported"
);
}
protected TemporalJavaType<T> forTimePrecision(TypeConfiguration typeConfiguration) {
throw new UnsupportedOperationException(
getTypeName() + " as TemporalType.TIME not supported"
);
}
@Override
public String toString() {
return "TemporalJavaType(javaType=" + getTypeName() + ")";
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Drop @Temporal from java.time fields and rely on the type's natural precision
- Use LocalTime / java.sql.Time / java.util.Date when time-of-day semantics are needed
- Correct the annotation to match the field (DATE for LocalDate, TIMESTAMP for LocalDateTime)
- Search the codebase for @Temporal(TemporalType.TIME) and verify each field type
Example fix
// before
@Entity
public class Holiday {
@Temporal(TemporalType.TIME) // LocalDate has no time precision
private LocalDate day;
}
// after
@Entity
public class Holiday {
@Temporal(TemporalType.DATE) // or remove: LocalDate is DATE by default
private java.util.Date day;
} Defensive patterns
Strategy: validation
Validate before calling
for (Field f : entity.getDeclaredFields()) {
Temporal t = f.getAnnotation(Temporal.class);
if (t != null && t.value() == TemporalType.TIME && !supportsTimePrecision(f.getType())) {
throw new MappingException("TIME precision invalid for " + f);
}
} Type guard
static boolean supportsTimePrecision(Class<?> fieldType) {
return Date.class.isAssignableFrom(fieldType) || Calendar.class.isAssignableFrom(fieldType)
|| fieldType == LocalTime.class || fieldType == OffsetTime.class
|| fieldType == java.sql.Time.class;
} Try / catch
try {
session.persist(holiday);
} catch (UnsupportedOperationException e) {
if (String.valueOf(e.getMessage()).contains("as TemporalType.TIME not supported")) {
throw new MappingException("Fix @Temporal(TIME) on non-time field", e);
}
throw e;
} Prevention
- Use LocalTime for time-of-day fields with no @Temporal
- Validate annotation/field-type pairs in a bootstrap test
- Delete stale @Temporal annotations rather than commenting them out
- Watch for copy-pasted annotations when splitting a Date field into date+time fields
When it happens
Trigger: @Temporal(TemporalType.TIME) on a date-only or timestamp field (LocalDate, LocalDateTime, java.sql.Date), or a programmatic request for time precision on a descriptor that only overrides date/timestamp handling.
Common situations: Mismatched @Temporal annotations after refactoring field types; validators or tooling requesting TIME precision for DATE columns; legacy entities moved from java.util.Date to LocalDate while @Temporal(TIME) remained.
Related errors
- getTypeName() + " as TemporalType.TIMESTAMP not supported"
- getTypeName() + " as TemporalType.DATE not supported"
- Basic array has element type '" + componentJavaType.getTypeN
- Duplicate named query '%s'
- Duplicate named stored procedure '{}'
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/4743bff225f29734.
Report an issue: GitHub.