{"record":{"id":"cc869f80fefff8ae","repo":"hibernate/hibernate-orm","slug":"could-not-locate-table-name","errorCode":null,"errorMessage":"Could not locate Table : \" + name","messagePattern":"Could not locate Table : \" \\+ name","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java","lineNumber":1208,"sourceCode":"\t}\n\n\t@Override\n\tpublic Table findTable(String name) {\n\t\tif ( getTable().getName().equals( name ) ) {\n\t\t\treturn getTable();\n\t\t}\n\t\tfinal var secondaryTable = findSecondaryTable( name );\n\t\tif ( secondaryTable != null ) {\n\t\t\treturn secondaryTable.getTable();\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic Table getTable(String name) {\n\t\tfinal var table = findTable( name );\n\t\tif ( table == null ) {\n\t\t\tthrow new MappingException( \"Could not locate Table : \" + name );\n\t\t}\n\t\treturn table;\n\t}\n\n\t@Override\n\tpublic Join findSecondaryTable(String name) {\n\t\tfor ( int i = 0; i < joins.size(); i++ ) {\n\t\t\tfinal var join = joins.get( i );\n\t\t\tif ( join.getTable().getNameIdentifier().matches( name ) ) {\n\t\t\t\treturn join;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic Join getSecondaryTable(String name) {\n\t\tfinal var secondaryTable = findSecondaryTable( name );","sourceCodeStart":1190,"sourceCodeEnd":1226,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java#L1190-L1226","documentation":"A table lookup by name failed: getTable(name) checks the primary table and all secondary tables (joins) and throws when none matches. The name must match the table's name identifier, and catalog/schema qualifiers make mismatches possible. It typically fires while resolving column-to-table references such as @Column(table=...) during binding or constraint creation.","triggerScenarios":"@Column(table = \"AUDIT\") on an entity that never declared @SecondaryTable(name = \"AUDIT\"); an hbm join element missing while a property table attribute references it; case or schema-qualified names that do not exactly match the declared table.","commonSituations":"Typos in secondary-table names; moving columns between tables during refactors; schemas where logical and physical names differ.","solutions":["Declare the secondary table on the entity with @SecondaryTable or a join element in hbm.xml","Make the referenced name match the declared table name exactly (case, catalog, schema)","Move the column back to the primary table if a secondary table was not intended"],"exampleFix":"// before\n@Entity\n@SecondaryTable(name = \"user_audit\")\n@Column(name = \"changed_at\", table = \"user_audits\") // typo\nprivate Instant changedAt;\n\n// after\n@Column(name = \"changed_at\", table = \"user_audit\")\nprivate Instant changedAt;","handlingStrategy":"validation","validationCode":"if (pc.findTable(tableName) == null) {\n    // the entity does not map this table (primary or secondary); declare it or fix the name\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare every @SecondaryTable on the entity that places columns in it","Use constants for table names to avoid typos between @SecondaryTable and @Column(table=...)","Prefer @TableGenerator-style naming checks in a startup assertion"],"tags":["hibernate","orm","secondary-table","table-lookup","mapping"],"backgroundTag":"unknown-table-reference","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}