Author: pcl
Date: Tue Aug 28 14:48:53 2007
New Revision: 570579

URL: http://svn.apache.org/viewvc?rev=570579&view=rev
Log:
OPENJPA-282. No test case.

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/PostgresDictionary.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=570579&r1=570578&r2=570579&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
 Tue Aug 28 14:48:53 2007
@@ -3038,7 +3038,7 @@
             return null;
         if (fk.getDeleteAction() == ForeignKey.ACTION_NONE)
             return null;
-        if (fk.isDeferred() && !supportsDeferredConstraints)
+        if (fk.isDeferred() && !supportsDeferredForeignKeyConstraints())
             return null;
         if (!supportsDeleteAction(fk.getDeleteAction())
             || !supportsUpdateAction(fk.getUpdateAction()))
@@ -3075,7 +3075,7 @@
             buf.append(" ON UPDATE ").append(upAction);
         if (fk.isDeferred())
             buf.append(" INITIALLY DEFERRED");
-        if (supportsDeferredConstraints)
+        if (supportsDeferredForeignKeyConstraints())
             buf.append(" DEFERRABLE");
         if (fk.getName() != null
             && CONS_NAME_AFTER.equals(constraintNameMode))
@@ -3084,6 +3084,16 @@
     }
 
     /**
+     * Whether or not this dictionary supports deferred foreign key 
constraints.
+     * This implementation returns [EMAIL PROTECTED] 
#supportsUniqueConstraints}.
+     *
+     * @since 1.1.0
+     */
+    protected boolean supportsDeferredForeignKeyConstraints() {
+        return supportsUniqueConstraints;
+    }
+
+    /**
      * Return the name of the given foreign key action.
      */
     private String getActionName(int action) {
@@ -3151,7 +3161,7 @@
      */
     protected String getUniqueConstraintSQL(Unique unq) {
         if (!supportsUniqueConstraints
-            || (unq.isDeferred() && !supportsDeferredConstraints))
+            || (unq.isDeferred() && !supportsDeferredUniqueConstraints()))
             return null;
 
         StringBuffer buf = new StringBuffer();
@@ -3165,12 +3175,22 @@
             append(")");
         if (unq.isDeferred())
             buf.append(" INITIALLY DEFERRED");
-        if (supportsDeferredConstraints)
+        if (supportsDeferredUniqueConstraints())
             buf.append(" DEFERRABLE");
         if (unq.getName() != null
             && CONS_NAME_AFTER.equals(constraintNameMode))
             buf.append(" CONSTRAINT ").append(unq.getName());
         return buf.toString();
+    }
+
+    /**
+     * Whether or not this dictionary supports deferred unique constraints.
+     * This implementation returns [EMAIL PROTECTED] 
#supportsUniqueConstraints}.
+     *
+     * @since 1.1.0
+     */
+    protected boolean supportsDeferredUniqueConstraints() {
+        return supportsUniqueConstraints;
     }
 
     /////////////////////

Modified: 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java?rev=570579&r1=570578&r2=570579&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
 (original)
+++ 
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
 Tue Aug 28 14:48:53 2007
@@ -271,6 +271,11 @@
         return sql;
     }
 
+    protected boolean supportsDeferredUniqueConstraints() {
+        // Postgres only supports deferred foreign key constraints.
+        return false;
+    }
+
     protected String getSequencesSQL(String schemaName, String sequenceName) {
         if (schemaName == null && sequenceName == null)
             return allSequencesSQL;


Reply via email to