HHH-8228 - enable foreign keys in HANA dialects by defaulting to 'ON UPDATE CASCADE'

This commit is contained in:
Andrew Clemons 2013-10-29 07:48:55 +13:00 committed by Brett Meyer
parent f52c14a652
commit 4e527d0f3e
2 changed files with 10 additions and 20 deletions

View File

@ -64,10 +64,8 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
* An abstract base class for HANA dialects. <br/> * An abstract base class for HANA dialects. <br/>
* <a href="http://help.sap.com/hana/html/sqlmain.html">SAP HANA Reference</a> <br/> * <a href="http://help.sap.com/hana/html/sqlmain.html">SAP HANA Reference</a> <br/>
* *
* NOTE: This dialect is currently configured to <b>not</b> create foreign keys by * NOTE: This dialect is currently configured to create foreign keys with
* returning the empty string from {@link #getAddForeignKeyConstraintString} since they currently have caveats compared * <code>on update cascade</code>.
* to other databases. This does not
* affect using this dialect with your own DDL scripts which use foreign keys.
* *
* @author Andrew Clemons <andrew.clemons@sap.com> * @author Andrew Clemons <andrew.clemons@sap.com>
*/ */
@ -574,14 +572,6 @@ public abstract class AbstractHANADialect extends Dialect {
return false; return false;
} }
@Override
public boolean supportsCascadeDelete() {
// HANA does support cascade deletes, but since we have (temporarily) overridden the foreign key support,
// this should also be false.
// TODO: Enable once FK support is solidified and getAddForeignKeyConstraintString is corrected.
return false;
}
@Override @Override
public ScrollMode defaultScrollMode() { public ScrollMode defaultScrollMode() {
return ScrollMode.FORWARD_ONLY; return ScrollMode.FORWARD_ONLY;
@ -673,14 +663,14 @@ public abstract class AbstractHANADialect extends Dialect {
} }
/** /**
* Currently disabling foreign key creation when using Hibernate's auto-ddl * The default behaviour for 'on update restrict' on HANA is currently
* feature. HANA does allow creating foreign keys, but currently they do not always * to not allow any updates to any column of a row if the row has a
* behave as expected. * foreign key. Make the default for foreign keys have 'on update cascade'
* to work around the issue.
*/ */
@Override @Override
public String getAddForeignKeyConstraintString(final String constraintName, final String[] foreignKey, public String getAddForeignKeyConstraintString(final String constraintName, final String[] foreignKey,
final String referencedTable, final String[] primaryKey, final boolean referencesPrimaryKey) { final String referencedTable, final String[] primaryKey, final boolean referencesPrimaryKey) {
// TODO: Re-evaluate in a later HANA release where, hopefully, this has been solidified. return super.getAddForeignKeyConstraintString(constraintName, foreignKey, referencedTable, primaryKey, referencesPrimaryKey) + " on update cascade";
return "";
} }
} }