cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r884470 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/
Date Thu, 26 Nov 2009 09:07:58 GMT
Author: aadamchik
Date: Thu Nov 26 09:07:57 2009
New Revision: 884470

URL: http://svn.apache.org/viewvc?rev=884470&view=rev
Log:
CAY-1247 Query SQL syntax with join and OR on Oracle8 (and maybe OpenBase)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8QualifierTranslator.java
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=884470&r1=884469&r2=884470&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Thu Nov 26 09:07:57 2009
@@ -28,6 +28,7 @@
 
 Bug Fixes Since beta1:
 
+CAY-1247 Query SQL syntax with join and OR on Oracle8 (and maybe OpenBase)
 CAY-1305 EJBQL doesn't support null parameters
 CAY-1307 Error committing CLOB on Oracle8
 CAY-1309 many validation errors when we remove dbEntity 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java?rev=884470&r1=884469&r2=884470&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java
Thu Nov 26 09:07:57 2009
@@ -23,6 +23,8 @@
 import java.net.URL;
 
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.trans.QualifierTranslator;
+import org.apache.cayenne.access.trans.QueryAssembler;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
 
@@ -54,7 +56,7 @@
             // ignoring...
         }
     }
-    
+
     static Method getWriterFromClobMethod() {
         return writerFromClobMethod;
     }
@@ -81,4 +83,9 @@
 
         return super.findResource(name);
     }
+
+    @Override
+    public QualifierTranslator getQualifierTranslator(QueryAssembler queryAssembler) {
+        return new Oracle8QualifierTranslator(queryAssembler);
+    }
 }

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8QualifierTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8QualifierTranslator.java?rev=884470&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8QualifierTranslator.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/Oracle8QualifierTranslator.java
Thu Nov 26 09:07:57 2009
@@ -0,0 +1,51 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.dba.oracle;
+
+import java.io.IOException;
+
+import org.apache.cayenne.access.trans.QueryAssembler;
+
+/**
+ * Extends the TrimmingQualifierTranslator that Cayenne normally uses for Oracle.
+ * Overrides doAppendPart() to wrap the qualifierBuffer in parentheses if it contains an
+ * "OR" expression. This avoids a bug that can happen on Oracle8 if the query also
+ * contains a join.
+ * 
+ * @since 3.0
+ */
+class Oracle8QualifierTranslator extends OracleQualifierTranslator {
+
+    public Oracle8QualifierTranslator(QueryAssembler queryAssembler) {
+        super(queryAssembler);
+    }
+
+    @Override
+    protected void doAppendPart() throws IOException {
+        super.doAppendPart();
+
+        if (out instanceof StringBuilder) {
+            StringBuilder buffer = (StringBuilder) out;
+            if (buffer.indexOf(" OR ") != -1) {
+                buffer.insert(0, '(');
+                buffer.append(')');
+            }
+        }
+    }
+}



Mime
View raw message