openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r772828 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DBDictionary.java MySQLDictionary.java
Date Fri, 08 May 2009 01:31:37 GMT
Author: ppoddar
Date: Fri May  8 01:31:37 2009
New Revision: 772828

URL: http://svn.apache.org/viewvc?rev=772828&view=rev
Log:
OPENJA-1070:support for composite foreign keys on MySQL Version >= 5

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=772828&r1=772827&r2=772828&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Fri May  8 01:31:37 2009
@@ -181,6 +181,7 @@
     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 @@
     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())

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java?rev=772828&r1=772827&r2=772828&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Fri May  8 01:31:37 2009
@@ -141,6 +141,7 @@
         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 @@
         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



Mime
View raw message