hibernate/hibernate-orm · error · SchemaExtractionException

Could not locate table information for %s

Error message

Could not locate table information for %s

What it means

During namespace-wide primary-key extraction, every resultset row must map back to a table the extraction context already knows: locateTableInformation(qualifiedTableName). A row whose catalog/schema/table identifiers resolve to no extracted table means the PK resultset references an object the table-extraction phase never saw, so Hibernate throws SchemaExtractionException naming the qualified name instead of guessing.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java:1013

						"Error while reading primary key meta data for namespace "
						+ new Namespace.Name( catalog, schema ) );
			}
		}
	}

	private TableInformation getTableInformation(
			@Nullable String catalogName,
			@Nullable String schemaName,
			@Nullable String tableName) {
		final var qualifiedTableName = new QualifiedTableName(
				toIdentifier( catalogName ),
				toIdentifier( schemaName ),
				toIdentifier( tableName )
		);
		final var tableInformation =
				extractionContext.getDatabaseObjectAccess().locateTableInformation( qualifiedTableName );
		if ( tableInformation == null ) {
			throw new SchemaExtractionException( "Could not locate table information for " + qualifiedTableName );
		}
		return tableInformation;
	}

	protected NameSpacePrimaryKeysInformation extractNameSpacePrimaryKeysInformation(ResultSet resultSet)
			throws SQLException {
		final var primaryKeysInformation = new NameSpacePrimaryKeysInformation( getIdentifierHelper() );

		while ( resultSet.next() ) {
			final String currentTableName = resultSet.getString( getResultSetPrimaryKeyTableLabel() );
			final String currentPkName = resultSet.getString( getResultSetPrimaryKeyNameLabel() );
			final Identifier currentPrimaryKeyIdentifier =
					currentPkName == null ? null : toIdentifier( currentPkName );
			final var tableInformation = getTableInformation(
					resultSet.getString( getResultSetPrimaryKeyCatalogLabel() ),
					resultSet.getString( getResultSetPrimaryKeySchemaLabel() ),
					currentTableName
			);

View on GitHub (pinned to fad1729dce)

Solutions

  1. Align identifier case and quoting: set hibernate.default_catalog / hibernate.default_schema to the exact stored form (often uppercase on Oracle) and quote only truly quoted objects.
  2. Restrict extraction to the single intended catalog/schema so rows from unrelated namespaces cannot leak in.
  3. Re-run when the schema is quiescent — concurrent DDL between the table and PK extraction phases causes exactly this mismatch.
Defensive patterns

Strategy: try-catch

Validate before calling

String storedSchema = connection.getMetaData().getSchemaTerm() != null
        ? connection.getSchema() : null;
// ensure configured default schema/catalog matches the stored form Hibernate will see
if (storedSchema != null && !storedSchema.equals(configuredDefaultSchema)) {
    props.put("hibernate.default_schema", storedSchema); // align case before hbm2ddl
}

Try / catch

try {
    schemaValidator.validate(metadata, databaseModel);
} catch (SchemaExtractionException e) {
    if (e.getMessage() != null && e.getMessage().contains("Could not locate table information")) {
        // identifier case/catalog/schema mismatch between PK rows and extracted tables — align and re-run
    }
    throw e;
}

Prevention

When it happens

Trigger: The bulk PK query reports identifiers that match no extracted table: case-normalizing drivers returning uppercase catalogs/schemas where table extraction recorded different casing; a table created or dropped between the two extraction queries; catalog/schema filters that differ between the table and PK queries.

Common situations: Oracle/SQL Server-style uppercase metadata versus Hibernate's stored identifier forms; quoted-identifier mappings on case-preserving databases; concurrent DDL during schema validation in CI pipelines.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/49b90029e705751f. Report an issue: GitHub.