{"record":{"id":"662167d1b54843b7","repo":"hibernate/hibernate-orm","slug":"no-create-schema-syntax-supported-by-getclass-662167","errorCode":null,"errorMessage":"\"No create schema syntax supported by \" + getClass().getName()","messagePattern":"\"No create schema syntax supported by \" \\+ getClass\\(\\)\\.getName\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java","lineNumber":1186,"sourceCode":"\t\t\t\t\ton 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'\n\t\t\t\tleft outer join INFORMATION_SCHEMA.SEQUENCE_OPTIONS skip_range_max\n\t\t\t\t\ton 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'\n\t\t\t\t\"\"\";\n\t}\n\n\t@Override\n\tpublic GenerationType getNativeValueGenerationStrategy() {\n\t\treturn GenerationType.SEQUENCE;\n\t}\n\n\t@Override\n\tpublic boolean canCreateSchema() {\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic String[] getCreateSchemaCommand(String schemaName) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\"No create schema syntax supported by \" + getClass().getName() );\n\t}\n\n\t@Override\n\tpublic String[] getDropSchemaCommand(String schemaName) {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\"No drop schema syntax supported by \" + getClass().getName() );\n\t}\n\n\t@Override\n\tpublic String getCurrentSchemaCommand() {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\t\"No current schema syntax supported by \" + getClass().getName() );\n\t}\n\n\t@Override\n\tpublic SchemaNameResolver getSchemaNameResolver() {\n\t\t// Spanner does not have a notion of database name schemas, so return \"\".","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java#L1168-L1204","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove schema/catalog attributes from @Table/@SequenceGenerator mappings (or override the physical naming strategy) so no schema DDL is requested on Spanner.","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.","If you drive schema tooling programmatically, guard with `if (dialect.canCreateSchema())` — SpannerDialect returns false — before invoking creation.","Use separate Spanner databases instead of schemas for isolation."],"exampleFix":"// before\n@Table(name = \"orders\", schema = \"sales\")\npublic class Order { ... }\n\n// after (Spanner has no schemas)\n@Table(name = \"orders\")\npublic class Order { ... }","handlingStrategy":"validation","validationCode":"if (sessionFactory.getJdbcServices().getDialect() instanceof SpannerDialect || dialect.canCreateSchema() == false) {\n  // skip schema creation; ensure mappings carry no schema names\n} else {\n  new SchemaExport(cfg).createOnly(target);\n}","typeGuard":null,"tryCatchPattern":"try {\n  export.createOnly(outputFile);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"create schema\")) { /* strip schema names from mappings and re-export tables only */ }\n  throw e;\n}","preventionTips":["Never map @Table(schema=...) on entities used with Spanner.","Prefer hbm2ddl.auto=none and manage Spanner DDL with its own tooling.","Guard schema tooling with dialect.canCreateSchema()."],"tags":["hibernate","cloud-spanner","dialect","ddl","schema-export","unsupportedoperationexception"],"backgroundTag":"schema-management-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}