openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1614935 - in /openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: OracleDictionary.java SQLBuffer.java
Date Thu, 31 Jul 2014 16:47:36 GMT
Author: hthomann
Date: Thu Jul 31 16:47:36 2014
New Revision: 1614935

URL: http://svn.apache.org/r1614935
Log:
OPENJPA-2131: Missing IN or OUT parameter exception with OracleDictionary - back ported Albert
Lee's trunk commit.

Modified:
    openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
    openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java

Modified: openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java?rev=1614935&r1=1614934&r2=1614935&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
(original)
+++ openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
Thu Jul 31 16:47:36 2014
@@ -363,10 +363,12 @@ public class OracleDictionary
         for (Iterator itr = aliases.iterator(); itr.hasNext(); i++) {
             alias = itr.next();
             String asString = null;
-            if (alias instanceof SQLBuffer)
+            if (alias instanceof SQLBuffer) {
                 asString = ((SQLBuffer) alias).getSQL();
-            else
+                selectSQL.appendParamOnly((SQLBuffer) alias);
+            } else {
                 asString = alias.toString();
+            }
             selectSQL.append(asString);
             if (asString.indexOf(" AS ") == -1)
                 selectSQL.append(" AS c").append(String.valueOf(i));

Modified: openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java?rev=1614935&r1=1614934&r2=1614935&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
(original)
+++ openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
Thu Jul 31 16:47:36 2014
@@ -103,16 +103,23 @@ public final class SQLBuffer
      * Append all SQL and parameters of the given buffer.
      */
     public SQLBuffer append(SQLBuffer buf) {
-        append(buf, _sql.length(), (_params == null) ? 0 : _params.size(),
-            true);
+        append(buf, _sql.length(), (_params == null) ? 0 : _params.size(), true, false);
         return this;
     }
 
     /**
-     * Append all SQL and parameters of the given buffer at the given positions.
+     * Append parameters only if the given buffer at the given positions.
+    */
+    public SQLBuffer appendParamOnly(SQLBuffer buf) {
+        append(buf, _sql.length(), (_params == null) ? 0 : _params.size(), true, true);
+        return this;
+    }
+
+    /**
+     * Append parameters and/or SQL of the given buffer at the given positions.
      */
     private void append(SQLBuffer buf, int sqlIndex, int paramIndex,
-        boolean subsels) {
+        boolean subsels, boolean paramOnly) {
         if (subsels) {
             // only allow appending of buffers with subselects, not insertion
             if (_subsels != null && !_subsels.isEmpty()
@@ -129,10 +136,12 @@ public final class SQLBuffer
             }
         }
 
-        if (sqlIndex == _sql.length())
-            _sql.append(buf._sql.toString());
-        else
-            _sql.insert(sqlIndex, buf._sql.toString());
+        if (!paramOnly) {
+            if (sqlIndex == _sql.length())
+                _sql.append(buf._sql.toString());
+            else
+                _sql.insert(sqlIndex, buf._sql.toString());
+        }
 
         if (buf._params != null) {
             if (_params == null)
@@ -547,7 +556,7 @@ public final class SQLBuffer
             else
                 buf = sub.select.toSelect(false, sub.fetch);
             buf.resolveSubselects();
-            append(buf, sub.sqlIndex, sub.paramIndex, false);
+            append(buf, sub.sqlIndex, sub.paramIndex, false, false);
         }
         _subsels.clear();
     }



Mime
View raw message