{"record":{"id":"3f04da1c041df346","repo":"hibernate/hibernate-orm","slug":"unsupported-temporal-unit-for-cubrid-unit","errorCode":null,"errorMessage":"unsupported temporal unit for CUBRID: \" + unit","messagePattern":"unsupported temporal unit for CUBRID: \" \\+ unit","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CUBRIDDialect.java","lineNumber":574,"sourceCode":"\t\t\t\ttimediff(pattern, MINUTE, unit);\n\t\t\t\tpattern.append(\"+\");\n\t\t\t\ttimediff(pattern, HOUR, unit);\n\t\t\t\tpattern.append(\")\");\n\t\t\t\tbreak;\n\t\t\tcase NATIVE:\n\t\t\tcase NANOSECOND:\n\t\t\t\tpattern.append(\"(\");\n\t\t\t\ttimediff(pattern, unit, unit);\n\t\t\t\tpattern.append(\"+\");\n\t\t\t\ttimediff(pattern, SECOND, unit);\n\t\t\t\tpattern.append(\"+\");\n\t\t\t\ttimediff(pattern, MINUTE, unit);\n\t\t\t\tpattern.append(\"+\");\n\t\t\t\ttimediff(pattern, HOUR, unit);\n\t\t\t\tpattern.append(\")\");\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new SemanticException(\"unsupported temporal unit for CUBRID: \" + unit);\n\t\t}\n\t\treturn pattern.toString();\n\t}\n\n\tprivate void timediff(\n\t\t\tStringBuilder sqlAppender,\n\t\t\tTemporalUnit diffUnit,\n\t\t\tTemporalUnit toUnit) {\n\t\tif ( diffUnit == NANOSECOND ) {\n\t\t\tsqlAppender.append(\"1e6*\");\n\t\t}\n\t\tsqlAppender.append(\"extract(\");\n\t\tif ( diffUnit == NANOSECOND || diffUnit == NATIVE ) {\n\t\t\tsqlAppender.append(\"millisecond\");\n\t\t}\n\t\telse {\n\t\t\tsqlAppender.append(\"?1\");\n\t\t}","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CUBRIDDialect.java#L556-L592","documentation":"resolveTableReference(navigablePath, tableExpression) asks a from-clause element (table group/reference) for the physical TableReference of a given table name and throws UnknownTableReferenceException when lookup returns null. Concretely: a column is about to be rendered against a table that this from-element does not contain - typically a secondary table, a subclass table, or the wrong side of an association that was never joined.","triggerScenarios":"Resolving a column whose mapped table is absent from the current table group: secondary-table (@SecondaryTable) columns on a join path that skipped the secondary table; subclass-specific tables in TABLE_PER_CLASS/union contexts; @ManyToOne target columns resolved without the target table joined; paths crossing a one-to-one mappedBy group; locking or native operations on derived mappings.","commonSituations":"Migrating apps to Hibernate 6/7 where secondary-table and inheritance resolution became stricter; criteria queries on a superclass selecting subclass-only attributes; queries touching the inverse side of one-to-one relations; mapping refactors where a column moved to another table while queries still ran.","solutions":["Ensure the association containing the column is actually joined in the query (HQL 'join fetch' / explicit join, criteria .join()) rather than referenced implicitly.","Query the concrete subclass or an entity type that actually maps the table named in the message.","Fix the mapping so the attribute is mapped to a table that is part of the queried table group (e.g. move the column, adjust @SecondaryTable usage).","Check custom table-group/persister code if present, then upgrade Hibernate - several UnknownTableReferenceException paths were fixed across 6.x/7.x."],"exampleFix":"// before: implicit reference to a table never joined\n\"select o from Order o where o.customer.vipCard.number is null\" // vipCard table not joined\n\n// after: explicit join so the table group contains the table\n\"select o from Order o join fetch o.customer c left join fetch c.vipCard v where v.number is null\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return em.createQuery(hql, type).getResultList();\n} catch ( UnknownTableReferenceException e ) {\n    // message: \"Unable to determine TableReference (`tbl`) for `path`\"\n    // add an explicit join for the association owning `tbl`, then retry\n    return em.createQuery(withExplicitJoin(hql, e.getTableExpression()), type).getResultList();\n}","preventionTips":["Always join (or join-fetch) associations whose columns you reference - do not rely on implicit resolution across secondary/subclass tables.","Run the full query suite on the production dialect; table-reference resolution differs by dialect path.","After moving columns between tables, grep queries and DTOs for the old attribute paths.","Keep Hibernate current - UnknownTableReferenceException paths get fixed across point releases."],"tags":["sql","table-reference","mapping","sql-ast","query-translation"],"backgroundTag":"unknown-table-reference","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}