{"record":{"id":"5c7a9946bd3535c6","repo":"hibernate/hibernate-orm","slug":"illegal-unit-for-timestamp-add-unit","errorCode":null,"errorMessage":"Illegal unit for timestamp_add(): ${unit}","messagePattern":"Illegal unit for timestamp_add\\(\\): (.+?)","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java","lineNumber":954,"sourceCode":"\t\t\tcase DAY_OF_MONTH:\n\t\t\t\treturn \"day\";\n\t\t\tcase DAY_OF_WEEK:\n\t\t\t\treturn \"dayofweek\";\n\t\t\tcase DAY_OF_YEAR:\n\t\t\t\treturn \"dayofyear\";\n\t\t\tdefault:\n\t\t\t\treturn super.translateExtractField(unit);\n\t\t}\n\t}\n\n\t@Override\n\tpublic String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {\n\t\tif ( temporalType == TemporalType.TIMESTAMP || temporalType == TemporalType.TIME ) {\n\t\t\tswitch ( unit ) {\n\t\t\t\tcase YEAR:\n\t\t\t\tcase QUARTER:\n\t\t\t\tcase MONTH:\n\t\t\t\t\tthrow new SemanticException( \"Illegal unit for timestamp_add(): \" + unit );\n\t\t\t\tcase WEEK:\n\t\t\t\t\treturn \"timestamp_add(?3, interval cast(?2 * 7 as int64) day)\";\n\t\t\t\tcase SECOND:\n\t\t\t\t\treturn \"timestamp_add(?3, interval cast(?2 * 1000000000 as int64) nanosecond)\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"timestamp_add(?3, interval cast(?2 as int64) ?1)\";\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tswitch ( unit ) {\n\t\t\t\tcase NANOSECOND:\n\t\t\t\tcase SECOND:\n\t\t\t\tcase MINUTE:\n\t\t\t\tcase HOUR:\n\t\t\t\tcase NATIVE:\n\t\t\t\t\tthrow new SemanticException( \"Illegal unit for date_add(): \" + unit );\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"date_add(?3, interval cast(?2 as int64) ?1)\";","sourceCodeStart":936,"sourceCodeEnd":972,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java#L936-L972","documentation":"Error \"Illegal unit for timestamp_add(): ${unit}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: Illegal unit for timestamp_add(): $the given unit.","commonSituations":"Common when running against a database whose dialect lacks this capability, when a mapping or HQL/Criteria query requests unsupported functionality, or when the wrong dialect is configured for the database in use. Error: Illegal unit for timestamp_add(): $the given unit.","solutions":["Use a unit supported by Spanner (e.g. DAY, HOUR, MINUTE, SECOND)."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}