diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java index 628f2c840..2383c2f3b 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java @@ -181,6 +181,7 @@ public class DBDictionary public int maxIndexNameLength = 128; public int maxIndexesPerTable = Integer.MAX_VALUE; public boolean supportsForeignKeys = true; + public boolean supportsForeignKeysComposite = true; public boolean supportsUniqueConstraints = true; public boolean supportsDeferredConstraints = true; public boolean supportsRestrictDeleteAction = true; @@ -3381,6 +3382,8 @@ public class DBDictionary protected String getForeignKeyConstraintSQL(ForeignKey fk) { if (!supportsForeignKeys) return null; + if (fk.getColumns().length > 0 && !supportsForeignKeysComposite) + return null; if (fk.getDeleteAction() == ForeignKey.ACTION_NONE) return null; if (fk.isDeferred() && !supportsDeferredForeignKeyConstraints()) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java index 5ff0aa6d9..a1752d55c 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java @@ -141,6 +141,7 @@ public class MySQLDictionary if (maj < 4 || (maj == 4 && min < 1)) { supportsSubselect = false; allowsAliasInBulkClause = false; + supportsForeignKeysComposite = false; } if (maj > 5 || (maj == 5 && min >= 1)) supportsXMLColumn = true; @@ -216,13 +217,6 @@ public class MySQLDictionary System.arraycopy(sql, 0, ret, cols.length, sql.length); return ret; } - - protected String getForeignKeyConstraintSQL(ForeignKey fk) { - // mysql does not support composite foreign keys - if (fk.getColumns().length > 1) - return null; - return super.getForeignKeyConstraintSQL(fk); - } public String[] getDeleteTableContentsSQL(Table[] tables) { // mysql >= 4 supports more-optimal delete syntax