openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r575080 - in /openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java
Date Wed, 12 Sep 2007 21:11:57 GMT
Author: fancy
Date: Wed Sep 12 14:11:56 2007
New Revision: 575080

URL: http://svn.apache.org/viewvc?rev=575080&view=rev
Log:
OPENJPA-360 FOR UPDATE clause incorrectly generated, remove transient variable declaration

Modified:
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=575080&r1=575079&r2=575080&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Wed Sep 12 14:11:56 2007
@@ -286,12 +286,12 @@
      * updateClause and isolationLevel hints
      */
     protected String getForUpdateClause(JDBCFetchConfiguration fetch,
-        boolean isForUpdate) {
+        boolean isForUpdate, Select sel) {
         int isolationLevel;
         // For db2UDBV81OrEarlier and db2ISeriesV5R3OrEarlier:
         // "optimize for" clause appears before "for update" clause.
         StringBuffer forUpdateString = new StringBuffer(
-            getOptimizeClause(fetch));
+            getOptimizeClause(sel));
         try {
             // Determine the isolationLevel; the fetch
             // configuration data overrides the persistence.xml value
@@ -437,7 +437,7 @@
         }
     }
 
-    protected String getOptimizeClause(JDBCFetchConfiguration fetch) {
+    protected String getOptimizeClause(Select sel) {
         if (sel != null && sel.getExpectedResultCount() > 0) {
             StringBuffer buf = new StringBuffer();
             buf.append(" ").append(optimizeClause).append(" ")

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=575080&r1=575079&r2=575080&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Sep 12 14:11:56 2007
@@ -58,7 +58,6 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.HashMap;
 import javax.sql.DataSource;
 
 import org.apache.commons.lang.StringUtils;
@@ -68,8 +67,6 @@
 import org.apache.openjpa.jdbc.kernel.exps.ExpContext;
 import org.apache.openjpa.jdbc.kernel.exps.ExpState;
 import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
-import org.apache.openjpa.jdbc.kernel.exps.Lit;
-import org.apache.openjpa.jdbc.kernel.exps.Param;
 import org.apache.openjpa.jdbc.kernel.exps.Val;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
@@ -86,7 +83,6 @@
 import org.apache.openjpa.jdbc.schema.Table;
 import org.apache.openjpa.jdbc.schema.Unique;
 import org.apache.openjpa.kernel.Filters;
-import org.apache.openjpa.kernel.exps.Path;
 import org.apache.openjpa.lib.conf.Configurable;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.jdbc.ConnectionDecorator;
@@ -319,7 +315,6 @@
     private Method _setBytes = null;
     private Method _setString = null;
     private Method _setCharStream = null;
-    protected transient Select sel = null;
 
     public DBDictionary() {
         fixedSizeTypeNameSet.addAll(Arrays.asList(new String[]{
@@ -1983,7 +1978,6 @@
      */
     public SQLBuffer toSelect(Select sel, boolean forUpdate,
         JDBCFetchConfiguration fetch) {
-        this.sel = sel;
         sel.addJoinClassConditions();
         boolean update = forUpdate && sel.getFromSelect() == null;
         SQLBuffer select = getSelects(sel, false, update);
@@ -1998,7 +1992,7 @@
         SQLBuffer where = getWhere(sel, update);
         return toSelect(select, fetch, from, where, sel.getGrouping(),
             sel.getHaving(), ordering, sel.isDistinct(), forUpdate,
-            sel.getStartIndex(), sel.getEndIndex());
+            sel.getStartIndex(), sel.getEndIndex(), sel);
     }
 
     /**
@@ -2186,7 +2180,20 @@
         boolean distinct, boolean forUpdate, long start, long end) {
         return toOperation(getSelectOperation(fetch), selects, from, where,
             group, having, order, distinct, start, end,
-            getForUpdateClause(fetch, forUpdate));
+            getForUpdateClause(fetch, forUpdate, null));
+    }
+
+    /**
+     * Combine the given components into a SELECT statement.
+     */
+    public SQLBuffer toSelect(SQLBuffer selects, JDBCFetchConfiguration fetch,
+        SQLBuffer from, SQLBuffer where, SQLBuffer group,
+        SQLBuffer having, SQLBuffer order,
+        boolean distinct, boolean forUpdate, long start, long end
+        , Select sel) {
+        return toOperation(getSelectOperation(fetch), selects, from, where,
+            group, having, order, distinct, start, end,
+            getForUpdateClause(fetch, forUpdate, sel));
     }
 
     /**
@@ -2194,7 +2201,7 @@
      * updateClause and isolationLevel hints
      */
     protected String getForUpdateClause(JDBCFetchConfiguration fetch,
-        boolean isForUpdate) {
+        boolean isForUpdate, Select sel) {
         if (fetch != null && fetch.getIsolation() != -1) {
             throw new InvalidStateException(_loc.get(
                 "isolation-level-config-not-supported", getClass().getName()));



Mime
View raw message