hibernate/hibernate-orm · error · UnsupportedOperationException

"No create schema syntax supported by " + getClass().getName

Error message

"No create schema syntax supported by " + getClass().getName()

What it means

SpannerDialect.getCreateSchemaCommand() unconditionally throws UnsupportedOperationException because Google Cloud Spanner has no CREATE SCHEMA syntax (schemas do not exist; it reports canCreateSchema()=false). The throw happens when Hibernate's schema management tooling asks the dialect for the DDL to create a schema, typically because hibernate.hbm2ddl.auto or the physical naming strategy produced a schema/namespace name. Any attempt to create a schema on Spanner is therefore a configuration error, not a database failure.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java:1186

					on seq.CATALOG=skip_range_min.CATALOG and seq.SCHEMA=skip_range_min.SCHEMA and seq.NAME=skip_range_min.NAME and skip_range_min.OPTION_NAME='skip_range_min'
				left outer join INFORMATION_SCHEMA.SEQUENCE_OPTIONS skip_range_max
					on seq.CATALOG=skip_range_max.CATALOG and seq.SCHEMA=skip_range_max.SCHEMA and seq.NAME=skip_range_max.NAME and skip_range_max.OPTION_NAME='skip_range_max'
				""";
	}

	@Override
	public GenerationType getNativeValueGenerationStrategy() {
		return GenerationType.SEQUENCE;
	}

	@Override
	public boolean canCreateSchema() {
		return false;
	}

	@Override
	public String[] getCreateSchemaCommand(String schemaName) {
		throw new UnsupportedOperationException(
				"No create schema syntax supported by " + getClass().getName() );
	}

	@Override
	public String[] getDropSchemaCommand(String schemaName) {
		throw new UnsupportedOperationException(
				"No drop schema syntax supported by " + getClass().getName() );
	}

	@Override
	public String getCurrentSchemaCommand() {
		throw new UnsupportedOperationException(
				"No current schema syntax supported by " + getClass().getName() );
	}

	@Override
	public SchemaNameResolver getSchemaNameResolver() {
		// Spanner does not have a notion of database name schemas, so return "".

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove schema/catalog attributes from @Table/@SequenceGenerator mappings (or override the physical naming strategy) so no schema DDL is requested on Spanner.
  2. Set hibernate.hbm2ddl.auto=none (or rely on Spanner migration tooling such as the Cloud Spanner Liquibase/JDBC wrappers) instead of letting Hibernate manage schemas.
  3. If you drive schema tooling programmatically, guard with `if (dialect.canCreateSchema())` — SpannerDialect returns false — before invoking creation.
  4. Use separate Spanner databases instead of schemas for isolation.

Example fix

// before
@Table(name = "orders", schema = "sales")
public class Order { ... }

// after (Spanner has no schemas)
@Table(name = "orders")
public class Order { ... }
Defensive patterns

Strategy: validation

Validate before calling

if (sessionFactory.getJdbcServices().getDialect() instanceof SpannerDialect || dialect.canCreateSchema() == false) {
  // skip schema creation; ensure mappings carry no schema names
} else {
  new SchemaExport(cfg).createOnly(target);
}

Try / catch

try {
  export.createOnly(outputFile);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().contains("create schema")) { /* strip schema names from mappings and re-export tables only */ }
  throw e;
}

Prevention

When it happens

Trigger: Running SchemaExport/SchemaUpdate or spring.jpa.properties.jakarta.persistence.schema-generation.* with an entity whose table is mapped to a non-empty catalog/schema (e.g. @Table(schema="app")), or executing new SchemaExport().createOnly() against a Spanner connection; Hibernate calls getCreateSchemaCommand(schemaName) before creating tables.

Common situations: Reusing entity mappings from a PostgreSQL project (where @Table(schema=...) is common) against a Spanner datasource; CI startup failing with hbm2ddl.auto=create while integration-testing on the Spanner emulator; multi-tenant code that programmatically creates schemas per tenant.

Related errors


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