{"record":{"id":"638c55520275bc61","repo":"hibernate/hibernate-orm","slug":"unsupported-specification-specification-638c55","errorCode":null,"errorMessage":"Unsupported specification: {specification}","messagePattern":"Unsupported specification: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java","lineNumber":354,"sourceCode":"\t}\n\n\t@Override\n\tpublic String trimPattern(TrimSpec specification, boolean isWhitespace) {\n\t\tswitch ( specification ) {\n\t\t\tcase BOTH:\n\t\t\t\treturn isWhitespace\n\t\t\t\t\t\t? \"trim(?1)\"\n\t\t\t\t\t\t: \"trim(?1,?2)\";\n\t\t\tcase LEADING:\n\t\t\t\treturn isWhitespace\n\t\t\t\t\t\t? \"ltrim(?1)\"\n\t\t\t\t\t\t: \"ltrim(?1,?2)\";\n\t\t\tcase TRAILING:\n\t\t\t\treturn isWhitespace\n\t\t\t\t\t\t? \"rtrim(?1)\"\n\t\t\t\t\t\t: \"rtrim(?1,?2)\";\n\t\t}\n\t\tthrow new UnsupportedOperationException( \"Unsupported specification: \" + specification );\n\t}\n\n\tprotected boolean supportsMathFunctions() {\n\t\t// Math functions have to be enabled through a compile time option: https://www.sqlite.org/lang_mathfunc.html\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {\n\t\tsuper.contributeTypes( typeContributions, serviceRegistry );\n\t\tfinal JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()\n\t\t\t\t.getJdbcTypeRegistry();\n\t\tjdbcTypeRegistry.addDescriptor( Types.BLOB, BlobJdbcType.PRIMITIVE_ARRAY_BINDING );\n\t\tjdbcTypeRegistry.addDescriptor( Types.CLOB, ClobJdbcType.STRING_BINDING );\n\t}\n\n\t@Override\n\tpublic LimitHandler getLimitHandler() {","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java#L336-L372","documentation":"SQLiteDialect.trimPattern throws UnsupportedOperationException when asked for the SQL pattern of a TRIM specification it does not map. The method switches over the three TrimSpec constants BOTH, LEADING and TRAILING (each with a whitespace-only shortcut); the trailing throw is a defensive guard that is effectively unreachable through normal Hibernate use because the TrimSpec enum defines exactly those three values. It can only fire from custom code that calls trimPattern directly, or from a version mismatch where a newer hibernate-orm introduces a TrimSpec constant this community-dialects release does not know.","triggerScenarios":"Directly calling dialect.trimPattern(spec, isWhitespace) with a value outside BOTH/LEADING/TRAILING from a custom Dialect or FunctionContributor; upgrading hibernate-orm ahead of hibernate-community-dialects so an unknown TrimSpec constant flows through.","commonSituations":"Dependency drift between hibernate-orm and hibernate-community-dialects (not using the hibernate-platform BOM); copy-pasting trimPattern into a custom SQLite subclass; dialect unit tests that pass mocked/extended enum values.","solutions":["If calling trimPattern directly, pass only TrimSpec.BOTH, TrimSpec.LEADING or TrimSpec.TRAILING","Align hibernate-community-dialects with the exact hibernate-orm version (use the hibernate-platform BOM) so no unknown TrimSpec exists","In a custom dialect subclass, override trimPattern to handle the extra constant instead of throwing"],"exampleFix":"// before - custom dialect helper passes a computed spec\nString pattern = dialect.trimPattern(spec, false);\n\n// after - guard first\nif (spec != TrimSpec.BOTH && spec != TrimSpec.LEADING && spec != TrimSpec.TRAILING) {\n    throw new IllegalArgumentException('Unsupported trim spec: ' + spec);\n}\nString pattern = dialect.trimPattern(spec, false);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isSupportedTrimSpec(TrimSpec spec) {\n    return spec == TrimSpec.BOTH || spec == TrimSpec.LEADING || spec == TrimSpec.TRAILING;\n}","tryCatchPattern":null,"preventionTips":["Pin hibernate-orm and hibernate-community-dialects to the same release via the hibernate-platform BOM","Never pass a computed or deserialized TrimSpec into trimPattern without an enum check","Cover all three TrimSpec values in custom-dialect unit tests"],"tags":["hibernate","sqlite","dialect","trim","sql-function","internal-invariant"],"backgroundTag":"unsupported-trim-specification","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}