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 <table name> 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 <table name> DROP FOREIGN KEY
+ * <fk name></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);