{"record":{"id":"b4f751281f29357d","repo":"hibernate/hibernate-orm","slug":"unrecognized-field-unit-b4f751","errorCode":null,"errorMessage":"Unrecognized field: ${unit}","messagePattern":"Unrecognized field: (.+?)","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java","lineNumber":557,"sourceCode":"\t\t\t// instead of an INTERVAL\n\t\t\treturn switch (unit) {\n\t\t\t\tcase YEAR, MONTH, QUARTER -> \"extract(\" + translateDurationField( unit ) + \" from age(?3,?2))\";\n\t\t\t\tdefault -> \"(?3-?2)\" + DAY.conversionFactor( unit, this );\n\t\t\t};\n\t\t}\n\t\telse {\n\t\t\treturn switch (unit) {\n\t\t\t\tcase YEAR -> \"extract(year from ?3-?2)\";\n\t\t\t\tcase QUARTER -> \"(extract(year from ?3-?2)*4+extract(month from ?3-?2)/3)\";\n\t\t\t\tcase MONTH -> \"(extract(year from ?3-?2)*12+extract(month from ?3-?2))\";\n\t\t\t\tcase WEEK -> \"(extract(day from ?3-?2)/7)\"; // week is not supported by extract() when the argument is a duration\n\t\t\t\tcase DAY -> \"extract(day from ?3-?2)\";\n\t\t\t\t// in order to avoid multiple calls to extract(),\n\t\t\t\t// we use extract(epoch from x - y) * factor for\n\t\t\t\t// all the following units:\n\t\t\t\tcase HOUR, MINUTE, SECOND, NANOSECOND, NATIVE ->\n\t\t\t\t\t\t\"extract(epoch from ?3-?2)\" + EPOCH.conversionFactor( unit, this );\n\t\t\t\tdefault -> throw new SemanticException( \"Unrecognized field: \" + unit );\n\t\t\t};\n\t\t}\n\t}\n\n\t@Override\n\tpublic TimeZoneSupport getTimeZoneSupport() {\n\t\treturn TimeZoneSupport.NORMALIZE;\n\t}\n\n\t@Override\n\tpublic void initializeFunctionRegistry(FunctionContributions functionContributions) {\n\t\tsuper.initializeFunctionRegistry( functionContributions );\n\n\t\tfinal var functionFactory = new CommonFunctionFactory( functionContributions );\n\n\t\tfunctionFactory.cot();\n\t\tfunctionFactory.radians();\n\t\tfunctionFactory.degrees();","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java#L539-L575","documentation":"Error \"Unrecognized field: ${unit}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: Unrecognized field: $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: Unrecognized field: $the given unit.","solutions":["Use a recognized temporal field name.","Verify the unit passed to the function."],"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"}