hibernate/hibernate-orm · error · UnsupportedOperationException
SingleStore does not support foreign keys and referential in
Error message
SingleStore does not support foreign keys and referential integrity.
What it means
SingleStoreDialect.getAddForeignKeyConstraintString(constraintName, foreignKey, referencedTable, primaryKey, referencesPrimaryKey) always throws because SingleStore does not support foreign keys or referential integrity: there is no ALTER TABLE ADD CONSTRAINT ... FOREIGN KEY to emit. Hibernate's schema migrator calls this overload when it must add an FK for a mapped association during hbm2ddl update. Any mapping that lets the tooling reach for FK DDL will fail on SingleStore.
Source
Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SingleStoreDialect.java:1211
return NameQualifierSupport.CATALOG;
}
@Override
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData metadata)
throws SQLException {
builder.setUnquotedCaseStrategy( IdentifierCaseStrategy.MIXED );
builder.setQuotedCaseStrategy( IdentifierCaseStrategy.MIXED );
return super.buildIdentifierHelper( builder, metadata );
}
@Override
public String getAddForeignKeyConstraintString(
String constraintName,
String[] foreignKey,
String referencedTable,
String[] primaryKey,
boolean referencesPrimaryKey) {
throw new UnsupportedOperationException(
"SingleStore does not support foreign keys and referential integrity." );
}
@Override
public String getAddForeignKeyConstraintString(String constraintName, String foreignKeyDefinition) {
throw new UnsupportedOperationException(
"SingleStore does not support foreign keys and referential integrity." );
}
@Override
public String getAddPrimaryKeyConstraintString(String constraintName) {
throw new UnsupportedOperationException( "SingleStore does not support altering primary key." );
}
@Override
public String getWriteLockString(String aliases, Timeout timeout) {
return getForUpdateString( aliases );
}View on GitHub (pinned to fad1729dce)
Solutions
- Mark associations with @ForeignKey(NO_CONSTRAINT) so no FK DDL is generated for SingleStore
- Turn off auto-DDL (hibernate.hbm2ddl.auto=none or validate) and manage schema with migrations
- Enforce parent/child consistency in the service layer or via ETL checks, since SingleStore will not enforce it
- In generated DDL pipelines, skip ALTER TABLE ADD FOREIGN KEY statements when the target is SingleStore
Example fix
// before - FK DDL generated for the association @ManyToOne @JoinColumn(name = 'customer_id') private Customer customer; // after - no constraint DDL @ManyToOne @JoinColumn(name = 'customer_id', foreignKey = @ForeignKey(NO_CONSTRAINT)) private Customer customer;
Defensive patterns
Strategy: validation
Validate before calling
static boolean emitsForeignKeyDdl(Dialect d) {
return !(d instanceof SingleStoreDialect);
}
// in schema generation:
if (emitsForeignKeyDdl(dialect)) {
ddl.add(dialect.getAddForeignKeyConstraintString(...));
} Prevention
- Use @ForeignKey(NO_CONSTRAINT) on every association in a SingleStore profile
- Disable auto-DDL on SingleStore; ship migrations instead
- Add a startup mapping scan that fails fast if FK DDL would be generated for SingleStore
When it happens
Trigger: hibernate.hbm2ddl.auto=update running after a new @ManyToOne/@JoinColumn association was added; SchemaExport create/update over mappings with FK-generating associations on SingleStore; DDL utilities that emit add-FK statements per dialect.
Common situations: Bringing a MySQL-designed entity model to SingleStore; auto-DDL enabled in a shared test profile; adding relationships during active development against a SingleStore dev database.
Related errors
- SingleStore does not support foreign keys and referential in
- No drop foreign key syntax supported by SQLiteDialect
- No add foreign key syntax supported by SQLiteDialect
- SingleStore does not support altering primary key.
- No add primary key syntax supported by SQLiteDialect
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/67b0a74fba3a7bf2.
Report an issue: GitHub.