{"record":{"id":"3de47a3ba0dd2ad9","repo":"hibernate/hibernate-orm","slug":"unit-is-not-a-legal-field-3de47a","errorCode":null,"errorMessage":"${unit} is not a legal field","messagePattern":"(.+?) is not a legal field","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java","lineNumber":706,"sourceCode":"\t\t\t\tbreak;\n\t\t\tcase DAY:\n\t\t\t\tif ( temporalType == TemporalType.DATE ) {\n\t\t\t\t\tpattern.append( \"(?3+(?2))\" );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tcase HOUR:\n\t\t\tcase MINUTE:\n\t\t\tcase SECOND:\n\t\t\t\tpattern.append( \"(?3+numtodsinterval(?2,'?1'))\" );\n\t\t\t\tbreak;\n\t\t\tcase NANOSECOND:\n\t\t\t\tpattern.append( \"(?3+numtodsinterval((?2)/1e9,'second'))\" );\n\t\t\t\tbreak;\n\t\t\tcase NATIVE:\n\t\t\t\tpattern.append( \"(?3+numtodsinterval(?2,'second'))\" );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new SemanticException( unit + \" is not a legal field\" );\n\t\t}\n\t\treturn pattern.toString();\n\t}\n\n\t@Override @SuppressWarnings(\"deprecation\")\n\tpublic String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {\n\t\tfinal var pattern = new StringBuilder();\n\t\tfinal boolean hasTimePart = toTemporalType != TemporalType.DATE || fromTemporalType != TemporalType.DATE;\n\t\tswitch ( unit ) {\n\t\t\tcase YEAR:\n\t\t\t\textractField( pattern, YEAR, unit );\n\t\t\t\tbreak;\n\t\t\tcase QUARTER:\n\t\t\tcase MONTH:\n\t\t\t\tpattern.append( \"(\" );\n\t\t\t\textractField( pattern, YEAR, unit );\n\t\t\t\tpattern.append( \"+\" );\n\t\t\t\textractField( pattern, MONTH, unit );","sourceCodeStart":688,"sourceCodeEnd":724,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java#L688-L724","documentation":"Error \"${unit} is not a legal field\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Triggered when the application calls a Hibernate dialect feature that the configured database dialect cannot provide: $the given unit is not a legal field.","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: $the given unit is not a legal field.","solutions":["Use a field supported by Oracle (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND).","Check the field name for typos."],"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"}