{"record":{"id":"4743bff225f29734","repo":"hibernate/hibernate-orm","slug":"gettypename-as-temporaltype-time-not-support","errorCode":null,"errorMessage":"getTypeName() + \" as TemporalType.TIME not supported\"","messagePattern":"getTypeName\\(\\) \\+ \" as TemporalType\\.TIME not supported\"","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractTemporalJavaType.java","lineNumber":68,"sourceCode":"\n\tprivate TemporalJavaType<T> forMissingPrecision(TypeConfiguration typeConfiguration) {\n\t\treturn this;\n\t}\n\n\tprotected TemporalJavaType<T> forTimestampPrecision(TypeConfiguration typeConfiguration) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\tgetTypeName() + \" as TemporalType.TIMESTAMP not supported\"\n\t\t);\n\t}\n\n\tprotected TemporalJavaType<T> forDatePrecision(TypeConfiguration typeConfiguration) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\tgetTypeName() + \" as TemporalType.DATE not supported\"\n\t\t);\n\t}\n\n\tprotected TemporalJavaType<T> forTimePrecision(TypeConfiguration typeConfiguration) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\tgetTypeName() + \" as TemporalType.TIME not supported\"\n\t\t);\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn \"TemporalJavaType(javaType=\" + getTypeName() + \")\";\n\t}\n}\n","sourceCodeStart":50,"sourceCodeEnd":78,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/AbstractTemporalJavaType.java#L50-L78","documentation":"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.).","triggerScenarios":"@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.","commonSituations":"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.","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"],"exampleFix":"// before\n@Entity\npublic class Holiday {\n    @Temporal(TemporalType.TIME) // LocalDate has no time precision\n    private LocalDate day;\n}\n// after\n@Entity\npublic class Holiday {\n    @Temporal(TemporalType.DATE) // or remove: LocalDate is DATE by default\n    private java.util.Date day;\n}","handlingStrategy":"validation","validationCode":"for (Field f : entity.getDeclaredFields()) {\n    Temporal t = f.getAnnotation(Temporal.class);\n    if (t != null && t.value() == TemporalType.TIME && !supportsTimePrecision(f.getType())) {\n        throw new MappingException(\"TIME precision invalid for \" + f);\n    }\n}","typeGuard":"static boolean supportsTimePrecision(Class<?> fieldType) {\n    return Date.class.isAssignableFrom(fieldType) || Calendar.class.isAssignableFrom(fieldType)\n        || fieldType == LocalTime.class || fieldType == OffsetTime.class\n        || fieldType == java.sql.Time.class;\n}","tryCatchPattern":"try {\n    session.persist(holiday);\n} catch (UnsupportedOperationException e) {\n    if (String.valueOf(e.getMessage()).contains(\"as TemporalType.TIME not supported\")) {\n        throw new MappingException(\"Fix @Temporal(TIME) on non-time field\", e);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["hibernate","orm","jpa","temporal-type","mapping-exception","date-time"],"backgroundTag":"temporal-precision-not-supported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}