{"record":{"id":"c68548d145a62b0e","repo":"hibernate/hibernate-orm","slug":"more-than-one-table-found-in-namespace-s-s","errorCode":null,"errorMessage":"More than one table found in namespace (%s, %s) : %s","messagePattern":"More than one table found in namespace \\((.+?), (.+?)\\) : (.+?)","errorType":"exception","errorClass":"SchemaExtractionException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java","lineNumber":805,"sourceCode":"\t}\n\n\tprivate TableInformation extractTableInformation(\n\t\t\tIdentifier catalog,\n\t\t\tIdentifier schema,\n\t\t\tIdentifier tableName,\n\t\t\tResultSet resultSet)\n\t\t\t\t\tthrows SQLException {\n\n\t\tboolean found = false;\n\t\tTableInformation tableInformation = null;\n\t\twhile ( resultSet.next() ) {\n\t\t\tfinal Identifier identifier =\n\t\t\t\t\ttoIdentifier( resultSet.getString( getResultSetTableNameLabel() ),\n\t\t\t\t\t\t\ttableName.isQuoted() );\n\t\t\tif ( tableName.equals( identifier ) ) {\n\t\t\t\tif ( found ) {\n\t\t\t\t\tCORE_LOGGER.multipleTablesFound( tableName.render() );\n\t\t\t\t\tthrow new SchemaExtractionException(\n\t\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\t\tLocale.ENGLISH,\n\t\t\t\t\t\t\t\t\t\"More than one table found in namespace (%s, %s) : %s\",\n\t\t\t\t\t\t\t\t\tcatalog == null ? \"\" : catalog.render(),\n\t\t\t\t\t\t\t\t\tschema == null ? \"\" : schema.render(),\n\t\t\t\t\t\t\t\t\ttableName.render()\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfound = true;\n\t\t\t\t\ttableInformation = extractTableInformation( resultSet );\n\t\t\t\t\taddColumns( tableInformation );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ( !found ) {\n\t\t\tCORE_LOGGER.tableNotFound( tableName.render() );","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java#L787-L823","documentation":"While extracting table metadata (schema validate/update/migration, reverse engineering), Hibernate walks the JDBC resultset looking for the requested table inside the namespace. More than one row resolving to the same requested Identifier means two physically distinct objects match — typically differing only in quoting or case — so extraction aborts with SchemaExtractionException rather than silently choosing one.","triggerScenarios":"Running hbm2ddl validate/update or hibernate-tools against a schema containing case/quoting-colliding tables (e.g. USER and \"User\") while the mapping asks for the unquoted name; drivers that match identifiers case-insensitively return multiple matches for the equality check.","commonSituations":"PostgreSQL/Oracle/H2 schemas with mixed-case legacy names; mappings that quote identifiers (backticks or global quoting) while the physical objects are unquoted, or vice versa; same table name in several catalogs when the catalog scope is unset.","solutions":["Make the mapping's identifiers match the physical objects exactly: adjust @Table/@Column names, quoting, or the physical naming strategy.","Scope the extraction: set hibernate.default_catalog / hibernate.default_schema (or the connection's current schema) so only the intended namespace is searched.","Rename or drop the accidental duplicate table when it is not intentional."],"exampleFix":"// before\n@Entity\n@Table(name = \"user\") // collides with USER in the same schema\npublic class User { ... }\n\n// after\n@Entity\n@Table(name = \"app_user\")\npublic class User { ... }","handlingStrategy":"try-catch","validationCode":"try (ResultSet rs = connection.getMetaData().getTables(catalog, schema, \"%\", new String[]{\"TABLE\"})) {\n    Map<String, Integer> seen = new HashMap<>();\n    while (rs.next()) {\n        String key = (rs.getString(2) + \".\" + rs.getString(3)).toLowerCase(Locale.ROOT);\n        seen.merge(key, 1, Integer::sum);\n    }\n    // any key with count > 1 after case-folding => collision risk before hbm2ddl runs\n}","typeGuard":null,"tryCatchPattern":"try {\n    schemaValidator.validate(metadata, databaseModel);\n} catch (SchemaExtractionException e) {\n    // e.getMessage() names the namespace and colliding table — fix quoting/naming, then re-run\n    throw e;\n}","preventionTips":["Keep mapping identifiers consistently quoted or unquoted across the whole model.","Set hibernate.default_catalog/default_schema so extraction cannot wander into other namespaces.","Prefer explicit @Table names over relying on naming strategies for legacy mixed-case schemas."],"tags":["hibernate","schema-extraction","jdbc-metadata","identifier-casing","naming-strategy"],"backgroundTag":"duplicate-table-in-schema","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}