{"record":{"id":"f7951883be45f43e","repo":"hibernate/hibernate-orm","slug":"unsupported-unit-unit-f79518","errorCode":null,"errorMessage":"Unsupported unit: {unit}","messagePattern":"Unsupported unit: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java","lineNumber":651,"sourceCode":"\t\t\t\t.replace(\"m\", \"%M\") //?????\n\n\t\t\t\t//second\n\t\t\t\t.replace(\"ss\", \"%S\")\n\t\t\t\t.replace(\"s\", \"%S\") //?????\n\n\t\t\t\t//fractional seconds\n\t\t\t\t.replace(\"SSSSSS\", \"%f\") //5 is the max\n\t\t\t\t.replace(\"SSSSS\", \"%f\")\n\t\t\t\t.replace(\"SSSS\", \"%f\")\n\t\t\t\t.replace(\"SSS\", \"%f\")\n\t\t\t\t.replace(\"SS\", \"%f\")\n\t\t\t\t.replace(\"S\", \"%f\");\n\t}\n\n\t@Override\n\tpublic String translateExtractField(TemporalUnit unit) {\n\t\t// All units should be handled in extractPattern so we should never hit this method\n\t\tthrow new UnsupportedOperationException( \"Unsupported unit: \" + unit );\n\t}\n\n\t@Override\n\tpublic void appendDateTimeLiteral(\n\t\t\tSqlAppender appender,\n\t\t\tTemporalAccessor temporalAccessor,\n\t\t\tTemporalType precision,\n\t\t\tTimeZone jdbcTimeZone) {\n\t\tswitch ( precision ) {\n\t\t\tcase DATE:\n\t\t\t\tappender.appendSql( \"date(\" );\n\t\t\t\tappendAsDate( appender, temporalAccessor );\n\t\t\t\tappender.appendSql( ')' );\n\t\t\t\tbreak;\n\t\t\tcase TIME:\n\t\t\t\tappender.appendSql( \"time(\" );\n\t\t\t\tappendAsTime( appender, temporalAccessor, supportsTemporalLiteralOffset(), jdbcTimeZone );\n\t\t\t\tappender.appendSql( ')' );","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java#L633-L669","documentation":"translateExtractField() is the generic fallback for rendering extract(), but the SQLite dialect implements every unit directly in extractPattern() with strftime-based templates. This override exists purely to fail fast: the source comment states all units are handled in extractPattern so the method should never be hit. Reaching it signals a mismatch between the dialect and the hibernate-orm version in use, or a custom code path that bypasses the dialect's extract patterns.","triggerScenarios":"Running hibernate-community-dialects against a different hibernate-orm version than it was built for (mixing ORM jars and dialect jars from different release trains); custom functions or a dialect subclass that route extract() through the generic translation path instead of the dialect's patterns.","commonSituations":"Dependency drift: hibernate-orm upgraded by a BOM while hibernate-community-dialects lagged behind (or vice versa); multiple hibernate-core versions on the classpath after merging dependencies; a custom SQLite subclass overriding extractPattern() and falling back to super for unhandled units.","solutions":["Align hibernate-orm and hibernate-community-dialects to the same release family, preferably via the hibernate-platform BOM","Verify with a dependency tree that only one hibernate-core version is on the classpath","In a custom SQLite dialect, override extractPattern() so every TemporalUnit you use returns a strftime pattern instead of falling through to the generic path"],"exampleFix":"// before - custom dialect lets unknown units fall through to the generic path\n@Override\npublic String extractPattern(TemporalUnit unit) {\n    return super.extractPattern(unit);\n}\n\n// after - map the units you actually use\n@Override\npublic String extractPattern(TemporalUnit unit) {\n    return switch (unit) {\n        case QUARTER -> 'cast(strftime(''%m'',?2) as integer)/3+1';\n        default -> super.extractPattern(unit);\n    };\n}","handlingStrategy":"validation","validationCode":"String orm = org.hibernate.Version.getVersionString();\nString dialects = SQLiteDialect.class.getPackage().getImplementationVersion();\nif (dialects != null && !orm.startsWith(dialects.substring(0, dialects.lastIndexOf('.')))) {\n    throw new IllegalStateException(\n        'hibernate-orm ' + orm + ' and hibernate-community-dialects ' + dialects\n        + ' are from different release trains; align them');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import the hibernate-platform BOM so ORM and community dialects upgrade together","Check the dependency tree for duplicate hibernate-core versions before release","Do not let a custom dialect fall back to the generic extract path; map every unit you use"],"tags":["hibernate","sqlite","dialect","extract","temporal-unit","internal-invariant"],"backgroundTag":"dialect-unsupported-extract-unit","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}