mirror of https://github.com/apache/openjpa.git
OPENJA-1070:support for composite foreign keys on MySQL Version >= 5
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@772828 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9a8246799c
commit
da17643624
|
@ -181,6 +181,7 @@ public class DBDictionary
|
||||||
public int maxIndexNameLength = 128;
|
public int maxIndexNameLength = 128;
|
||||||
public int maxIndexesPerTable = Integer.MAX_VALUE;
|
public int maxIndexesPerTable = Integer.MAX_VALUE;
|
||||||
public boolean supportsForeignKeys = true;
|
public boolean supportsForeignKeys = true;
|
||||||
|
public boolean supportsForeignKeysComposite = true;
|
||||||
public boolean supportsUniqueConstraints = true;
|
public boolean supportsUniqueConstraints = true;
|
||||||
public boolean supportsDeferredConstraints = true;
|
public boolean supportsDeferredConstraints = true;
|
||||||
public boolean supportsRestrictDeleteAction = true;
|
public boolean supportsRestrictDeleteAction = true;
|
||||||
|
@ -3381,6 +3382,8 @@ public class DBDictionary
|
||||||
protected String getForeignKeyConstraintSQL(ForeignKey fk) {
|
protected String getForeignKeyConstraintSQL(ForeignKey fk) {
|
||||||
if (!supportsForeignKeys)
|
if (!supportsForeignKeys)
|
||||||
return null;
|
return null;
|
||||||
|
if (fk.getColumns().length > 0 && !supportsForeignKeysComposite)
|
||||||
|
return null;
|
||||||
if (fk.getDeleteAction() == ForeignKey.ACTION_NONE)
|
if (fk.getDeleteAction() == ForeignKey.ACTION_NONE)
|
||||||
return null;
|
return null;
|
||||||
if (fk.isDeferred() && !supportsDeferredForeignKeyConstraints())
|
if (fk.isDeferred() && !supportsDeferredForeignKeyConstraints())
|
||||||
|
|
|
@ -141,6 +141,7 @@ public class MySQLDictionary
|
||||||
if (maj < 4 || (maj == 4 && min < 1)) {
|
if (maj < 4 || (maj == 4 && min < 1)) {
|
||||||
supportsSubselect = false;
|
supportsSubselect = false;
|
||||||
allowsAliasInBulkClause = false;
|
allowsAliasInBulkClause = false;
|
||||||
|
supportsForeignKeysComposite = false;
|
||||||
}
|
}
|
||||||
if (maj > 5 || (maj == 5 && min >= 1))
|
if (maj > 5 || (maj == 5 && min >= 1))
|
||||||
supportsXMLColumn = true;
|
supportsXMLColumn = true;
|
||||||
|
@ -216,13 +217,6 @@ public class MySQLDictionary
|
||||||
System.arraycopy(sql, 0, ret, cols.length, sql.length);
|
System.arraycopy(sql, 0, ret, cols.length, sql.length);
|
||||||
return ret;
|
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) {
|
public String[] getDeleteTableContentsSQL(Table[] tables) {
|
||||||
// mysql >= 4 supports more-optimal delete syntax
|
// mysql >= 4 supports more-optimal delete syntax
|
||||||
|
|
Loading…
Reference in New Issue