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.getDropForeignKeyString() always throws because SingleStore (formerly MemSQL) does not support foreign keys or referential integrity at all: there is no DROP CONSTRAINT for FKs to emit. Hibernate's schema tooling hits this method when it tries to drop a foreign key during schema update/drop over mappings that contain associations. This is a hard capability gap of the database, not a dialect bug.

Source

Thrown at hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SingleStoreDialect.java:946

				.replace( "mm", "%i" )
				.replace( "m", "%i" )

				//second
				.replace( "ss", "%S" )
				.replace( "s", "%S" )

				//fractional seconds
				.replace( "SSSSSS", "%f" )
				.replace( "SSSSS", "%f" )
				.replace( "SSSS", "%f" )
				.replace( "SSS", "%f" )
				.replace( "SS", "%f" )
				.replace( "S", "%f" );
	}

	@Override
	public String getDropForeignKeyString() {
		throw new UnsupportedOperationException(
				"SingleStore does not support foreign keys and referential integrity" );
	}

	@Override
	public String getDropUniqueKeyString() {
		return "drop index";
	}

	@Override
	public String getAlterColumnTypeString(String columnName, String columnType, String columnDefinition) {
		// no way to change just the column type, leaving other attributes intact
		return "modify column " + columnName + " " + columnDefinition.trim();
	}

	/**
	 * SingleStore doesn't support modifying column type on columnstore tables.
	 * It only supports modifying column type on rowstore table.
	 */

View on GitHub (pinned to fad1729dce)

Solutions

  1. Set hibernate.hbm2ddl.auto=none (or validate-only after aligning mappings) and manage DDL with migrations
  2. Annotate associations with @ForeignKey(NO_CONSTRAINT) so schema tooling never generates FK DDL for SingleStore
  3. Enforce referential integrity in the service layer, since SingleStore will not enforce it
  4. In custom tooling, gate drop-FK statements on dialect.dropConstraints() before asking for SQL

Example fix

// before - association produces FK DDL SingleStore cannot execute
@ManyToOne
@JoinColumn(name = 'customer_id')
private Customer customer;

// after - no constraint DDL is generated
@ManyToOne
@JoinColumn(name = 'customer_id', foreignKey = @ForeignKey(NO_CONSTRAINT))
private Customer customer;
Defensive patterns

Strategy: validation

Validate before calling

Dialect dialect = sessionFactory.getJdbcServices().getDialect();
if (dialect.dropConstraints()) {
    ddl.add(dialect.getDropForeignKeyString());
}
// SingleStore throws from these methods: its dropConstraints()/FK capability is absent,
// so the FK drop must be skipped entirely

Prevention

When it happens

Trigger: SchemaUpdate/SchemaExport drop or update (hibernate.hbm2ddl.auto=update, or explicit SchemaExport.drop) over mappings containing @ManyToOne/@OneToMany FK constraints on SingleStore; generic DDL utilities that ask every dialect for drop-FK SQL.

Common situations: Pointing an application originally written for MySQL at SingleStore; auto-DDL left enabled from a local test profile; CI running drop-and-create cycles against a SingleStore container.

Related errors


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