openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtyle...@apache.org
Subject svn commit: r784404 - /openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Date Sat, 13 Jun 2009 14:59:29 GMT
Author: mtylenda
Date: Sat Jun 13 14:59:29 2009
New Revision: 784404

URL: http://svn.apache.org/viewvc?rev=784404&view=rev
Log:
OPENJPA-1132: Use MySQL-specific syntax for dropping foreign and primary keys.

Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java?rev=784404&r1=784403&r2=784404&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
Sat Jun 13 14:59:29 2009
@@ -199,6 +199,37 @@
             + getFullName(index.getTable(), false) };
     }
 
+    /**
+     * Return <code>ALTER TABLE &lt;table name&gt; DROP PRIMARY KEY</code>.
+     */
+    @Override
+    public String[] getDropPrimaryKeySQL(PrimaryKey pk) {
+        if (pk.getName() == null)
+            return new String[0];
+        return new String[]{ "ALTER TABLE "
+            + getFullName(pk.getTable(), false)
+            + " DROP PRIMARY KEY" };
+    }
+
+    /**
+     * Return <code>ALTER TABLE &lt;table name&gt; DROP FOREIGN KEY
+     * &lt;fk name&gt;</code>.
+     */
+    @Override
+    public String[] getDropForeignKeySQL(ForeignKey fk, Connection conn) {
+        if (fk.getName() == null) {
+            String fkName = fk.loadNameFromDB(this,conn);
+            String[] retVal = (fkName == null) ?  new String[0] :
+                new String[]{ "ALTER TABLE "
+                + getFullName(fk.getTable(), false)
+                + " DROP FOREIGN KEY " + fkName };
+            return retVal;   
+        }
+        return new String[]{ "ALTER TABLE "
+            + getFullName(fk.getTable(), false)
+            + " DROP FOREIGN KEY " + fk.getName() };
+    }
+
     public String[] getAddPrimaryKeySQL(PrimaryKey pk) {
         String[] sql = super.getAddPrimaryKeySQL(pk);
 



Mime
View raw message