Author: mprudhom
Date: Mon Sep 11 16:17:27 2006
New Revision: 442385

URL: http://svn.apache.org/viewvc?view=rev&rev=442385
Log:
Don't bother using a subselect in bulk UPDATE or DELETE clauses if there is no 
where condition, since it does the exact same think as an unqulaified bulk 
operation.

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

Modified: 
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: 
http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=442385&r1=442384&r2=442385
==============================================================================
--- 
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
 (original)
+++ 
incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
 Mon Sep 11 16:17:27 2006
@@ -1792,6 +1792,17 @@
             return sql;
         }
 
+        Table table = mapping.getTable();
+        String tableName = getFullName(table, false);
+
+        // only use a  subselect if the where is not empty; otherwise
+        // an unqualified delete or update will work
+        if (sel.getWhere() == null || sel.getWhere().isEmpty()) {
+            sql.append(tableName);
+            appendUpdates(sel, store, sql, params, updateParams, false);
+            return sql;
+        }
+
         // we need to use a subselect if we are to bulk delete where
         // the select includes multiple tables; if the database
         // doesn't support it, then we need to sigal this by returning null
@@ -1799,8 +1810,6 @@
             return null;
 
         Column[] pks = mapping.getPrimaryKeyColumns();
-        Table table = mapping.getTable();
-        String tableName = getFullName(table, false);
         sel.clearSelects();
         sel.setDistinct(true);
 


Reply via email to