From f2b82449da4e19bea8d4d264be90ef39efed2618 Mon Sep 17 00:00:00 2001 From: Baptiste Mathus Date: Tue, 10 Dec 2013 11:39:11 +0100 Subject: [PATCH] HHH-9038 Fix HSQLDB dialect for non-existing constraints. This commits relates to https://hibernate.atlassian.net/browse/HHH-7002. It basically removes the explicit constraints dropping, and uses cascading instead. As HSQLDB requires to put CASCADE last, but fortunately accepts IF EXISTS also before tablename, we just put the IF EXISTS *before* the tablename, and CASCADE after it. And there you go. --- .../org/hibernate/dialect/HSQLDialect.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java index 6261297273..3c3c96d363 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java @@ -313,8 +313,16 @@ public class HSQLDialect extends Dialect { return hsqldbVersion < 200; } + // Note : HSQLDB actually supports [IF EXISTS] before AND after the + // But as CASCADE has to be AFTER IF EXISTS in case it's after the tablename, + // We put the IF EXISTS before the tablename to be able to add CASCADE after. @Override public boolean supportsIfExistsAfterTableName() { + return false; + } + + @Override + public boolean supportsIfExistsBeforeTableName() { return true; } @@ -684,4 +692,15 @@ public class HSQLDialect extends Dialect { public boolean supportsNamedParameters(DatabaseMetaData databaseMetaData) throws SQLException { return false; } + + // Do not drop constraints explicitly, just do this by cascading instead. + @Override + public boolean dropConstraints() { + return false; + } + + @Override + public String getCascadeConstraintsString() { + return " CASCADE "; + } }