{"record":{"id":"16133ebbc07e922f","repo":"hibernate/hibernate-orm","slug":"inconvertible-unit-this","errorCode":null,"errorMessage":"Inconvertible unit \" + this","messagePattern":"Inconvertible unit \" \\+ this","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/common/TemporalUnit.java","lineNumber":259,"sourceCode":"\t\t\tcase WEEK:\n\t\t\t\tfactor *= 7;\n\t\t\t\t//conversion to nanos:\n\t\t\tcase DAY:\n\t\t\t\tfactor *= 24;\n\t\t\tcase HOUR:\n\t\t\t\tfactor *= 60;\n\t\t\tcase MINUTE:\n\t\t\t\tfactor *= 60;\n\t\t\tcase EPOCH:\n\t\t\tcase SECOND:\n\t\t\t\tfactor *= 1_000_000_000;\n\t\t\tcase NANOSECOND:\n\t\t\t\tbreak;\n\t\t\tcase NATIVE:\n\t\t\t\tfactor *= dialect.getFractionalSecondPrecisionInNanos();\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new SemanticException(\"Inconvertible unit \" + this);\n\t\t}\n\t\treturn factor;\n\t}\n\n\t/**\n\t * Obtain a fragment of SQL that can be used to perform\n\t * a unit conversion. If the normalization factor is\n\t * very large, represent it using exponential form so\n\t * as to minimize the noise the generated SQL.\n\t *\n\t * @param factor the conversion factor\n\t * @return a string to inject into the SQL expression\n\t */\n\tprivate static String factorAsString(long factor) {\n\t\tString string = String.valueOf(factor);\n\t\tint len = string.length();\n\t\tint chop;\n\t\tfor (chop = len; chop>0 && string.charAt(chop-1)=='0'; chop--) {}","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/common/TemporalUnit.java#L241-L277","documentation":"Error \"Inconvertible unit \" + this\" thrown in hibernate/hibernate-orm.","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 temporal unit with a fixed duration for conversion.","Handle month/year units separately in application code."],"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"}