hibernate/hibernate-orm · error · SchemaExtractionException
Could not locate table information for %s
Error message
Could not locate table information for %s
What it means
SchemaExtractionException from DatabaseInformationImpl.locateNonNullTableInformation: Hibernate needs a table's JDBC-level TableInformation to enumerate its foreign keys (locateForeignKeyInformation) or indexes (locateIndexesInformation), but locateTableInformation returned null - no table exists under that qualified name once catalog/schema defaults are applied. The mapping references a table the live database does not have.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/DatabaseInformationImpl.java:183
@Override
public PrimaryKeyInformation locatePrimaryKeyInformation(QualifiedTableName tableName) {
return extractor.getPrimaryKey( locateNonNullTableInformation( tableName ) );
}
@Override
public Iterable<ForeignKeyInformation> locateForeignKeyInformation(QualifiedTableName tableName) {
return extractor.getForeignKeys( locateNonNullTableInformation( tableName ) );
}
@Override
public Iterable<IndexInformation> locateIndexesInformation(QualifiedTableName tableName) {
return extractor.getIndexes( locateNonNullTableInformation( tableName ) );
}
private TableInformation locateNonNullTableInformation(QualifiedTableName tableName) {
final TableInformation tableInformation = locateTableInformation( tableName );
if ( tableInformation == null ) {
throw new SchemaExtractionException( "Could not locate table information for " + tableName );
}
return tableInformation;
}
@Override
public boolean isCaching() {
return false;
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Verify the table exists with exact case in exactly the catalog/schema the connection resolves (SELECT ... FROM information_schema.tables).
- Align the mapped name with the physical name: fix @Table(name=...) or configure a consistent PhysicalNamingStrategy (e.g. CamelCaseToUnderscoresNamingStrategy).
- Set hibernate.default_schema / hibernate.default_catalog explicitly when the connection's default namespace differs from the mapped one.
- Ensure the schema is created first (run migrations or SchemaExport create) before update/validate passes that resolve FK/index metadata.
Example fix
// before: mapping name does not match the physical table on a case-sensitive DB
@Entity
@Table(name = "OrderLine")
public class OrderLine { ... }
// after: match the physical table exactly (or let the naming strategy produce it)
@Entity
@Table(name = "order_line")
public class OrderLine { ... } Defensive patterns
Strategy: validation
Validate before calling
// Before update/validate, confirm the table resolves in live JDBC metadata (locateTableInformation returns null instead of throwing)
DatabaseInformation dbInfo = ...; // from HibernateSchemaManagementTool extraction context
TableInformation ti = dbInfo.locateTableInformation(
new QualifiedTableName(
Identifier.toIdentifier(catalog),
Identifier.toIdentifier(schema),
Identifier.toIdentifier("order_line")));
if (ti == null) {
// create the table or fix naming/schema config before proceeding
} Try / catch
try {
schemaMigrator.doMigration(metadata, executionOptions, inclusionFilter, target);
} catch (SchemaManagementException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Could not locate table information")) {
// extract the qualified table name from the message, compare with the physical schema, fix naming/schema settings
}
throw e;
} Prevention
- Apply one PhysicalNamingStrategy (e.g. CamelCaseToUnderscoresNamingStrategy) consistently at create time and validate time
- Set hibernate.default_schema/default_catalog explicitly rather than relying on connection defaults
- Run hbm2ddl validate in CI against a freshly migrated schema so drift is caught before deployment
When it happens
Trigger: Calling locateForeignKeyInformation/locateIndexesInformation during SchemaUpdate or SchemaValidator passes when getTableInformation for the same qualified name is null: the table was never created, the connection resolves a different catalog/schema, or identifier case/quoting mismatches (PostgreSQL folding unquoted CamelCase to lowercase, quoted vs unquoted names, PhysicalNamingStrategy changes).
Common situations: Entity @Table(name = "OrderLine") validated against a PostgreSQL table physically named order_line; JDBC URL pointing at the wrong database or missing hibernate.default_schema; running update against an empty schema; changing the physical naming strategy between Hibernate versions so generated names no longer match.
Related errors
- More than one table found in namespace (%s, %s) : %s
- Primary Key information was missing for key [%s] on table [%
- Unable to find physical table: {}
- No column with logical name '{}' in table '{}'
- Table '${table}' has no column named '${column}' matching th
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/895cc15e655b54a0.
Report an issue: GitHub.