{"record":{"id":"082259e341392bbc","repo":"hibernate/hibernate-orm","slug":"unsure-how-to-handle-given-java-type-as-tempo-082259","errorCode":null,"errorMessage":"Unsure how to handle given Java type [{}] as TemporalType#TIME","messagePattern":"Unsure how to handle given Java type \\[(.+?)\\] as TemporalType#TIME","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/internal/BindingTypeHelper.java","lineNumber":193,"sourceCode":"\n\tprivate static BindableType<?> resolveTimeTemporalTypeVariant(\n\t\t\tClass<?> javaType,\n\t\t\tBindableType<?> baseType,\n\t\t\tTypeConfiguration typeConfiguration) {\n\t\tif ( Calendar.class.isAssignableFrom( javaType ) ) {\n\t\t\treturn typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.CALENDAR_TIME );\n\t\t}\n\t\telse if ( java.util.Date.class.isAssignableFrom( javaType ) ) {\n\t\t\treturn typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.TIME );\n\t\t}\n\t\telse if ( LocalTime.class.isAssignableFrom( javaType ) ) {\n\t\t\treturn typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.LOCAL_TIME );\n\t\t}\n\t\telse if ( OffsetTime.class.isAssignableFrom( javaType ) ) {\n\t\t\treturn typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.OFFSET_TIME );\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException( \"Unsure how to handle given Java type [\"\n\t\t\t\t\t\t\t\t\t\t\t\t+ javaType.getName() + \"] as TemporalType#TIME\" );\n\t\t}\n\t}\n}\n","sourceCodeStart":175,"sourceCodeEnd":198,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/internal/BindingTypeHelper.java#L175-L198","documentation":"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.","triggerScenarios":"Query.setParameter('t', LocalDateTime.now(), TemporalType.TIME) or LocalDate with TIME precision; binding any date-only or timestamp type with TemporalType.TIME.","commonSituations":"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.","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."],"exampleFix":"// before - LocalDateTime cannot be bound as TIME\nquery.setParameter(\"t\", LocalDateTime.now(), TemporalType.TIME);\n\n// after - convert to the time part\nquery.setParameter(\"t\", LocalDateTime.now().toLocalTime());","handlingStrategy":"type-guard","validationCode":"static final Set<Class<?>> TIME_OK = Set.of(\n    java.util.Calendar.class, java.util.Date.class,\n    java.time.LocalTime.class, java.time.OffsetTime.class );\n\nif ( !TIME_OK.contains( value.getClass() ) ) {\n    throw new IllegalArgumentException( \"Type \" + value.getClass().getSimpleName()\n        + \" cannot be bound with TemporalType.TIME\" );\n}","typeGuard":"static boolean supportsTimePrecision(Object v) {\n    return v instanceof java.util.Calendar || v instanceof java.util.Date\n        || v instanceof java.time.LocalTime || v instanceof java.time.OffsetTime;\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["hibernate","jpa","query-parameters","temporal","time"],"backgroundTag":"temporal-type-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}