{"record":{"id":"8fa41a266c654134","repo":"hibernate/hibernate-orm","slug":"illegal-unit-this","errorCode":null,"errorMessage":"Illegal unit \" + this","messagePattern":"Illegal unit \" \\+ this","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/common/TemporalUnit.java","lineNumber":349,"sourceCode":"\t * durations.\n\t */\n\tpublic TemporalUnit normalized() {\n\t\tswitch (this) {\n\t\t\tcase NANOSECOND:\n\t\t\tcase NATIVE:\n\t\t\tcase HOUR:\n\t\t\tcase MINUTE:\n\t\t\tcase SECOND:\n\t\t\tcase EPOCH:\n\t\t\tcase DAY:\n\t\t\tcase WEEK:\n\t\t\t\treturn NANOSECOND;\n\t\t\tcase YEAR:\n\t\t\tcase QUARTER:\n\t\t\tcase MONTH:\n\t\t\t\treturn MONTH;\n\t\t\tdefault:\n\t\t\t\tthrow new SemanticException(\"Illegal unit \" + this);\n\t\t}\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn super.toString().toLowerCase();\n\t}\n}\n","sourceCodeStart":331,"sourceCodeEnd":358,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/common/TemporalUnit.java#L331-L358","documentation":"Thrown by TemporalUnit.normalized() when the enum constant has no assigned normalization family. The method maps every unit either to NANOSECOND (duration-based units) or MONTH (calendar-based units); hitting the default branch means an unlisted/unsupported unit was passed through the type hierarchy — an internal invariant violation rather than a user input error.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Use a supported TemporalUnit in this context.","Check the unit against the database dialect's supported units."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}