cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1036017 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2QualifierTranslator.java
Date Wed, 17 Nov 2010 12:53:17 GMT
Author: oltka
Date: Wed Nov 17 12:53:16 2010
New Revision: 1036017

URL: http://svn.apache.org/viewvc?rev=1036017&view=rev
Log:
CAY-1511 Problem in db2: comparison operators are not supported on Clob object values.

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2QualifierTranslator.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2QualifierTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2QualifierTranslator.java?rev=1036017&r1=1036016&r2=1036017&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2QualifierTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2QualifierTranslator.java
Wed Nov 17 12:53:16 2010
@@ -27,6 +27,9 @@ import org.apache.cayenne.access.trans.Q
 import org.apache.cayenne.access.trans.TrimmingQualifierTranslator;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.parser.ASTEqual;
+import org.apache.cayenne.exp.parser.ASTNotEqual;
+import org.apache.cayenne.exp.parser.SimpleNode;
 import org.apache.cayenne.map.DbAttribute;
 
 /**
@@ -97,4 +100,32 @@ public class DB2QualifierTranslator exte
             out.append(")");
         }
     }
+    
+    @Override
+    protected void processColumnWithQuoteSqlIdentifiers(
+            DbAttribute dbAttr,
+            Expression pathExp) throws IOException {
+
+        SimpleNode parent = null;
+        if (pathExp instanceof SimpleNode) {
+            parent = (SimpleNode) ((SimpleNode) pathExp).jjtGetParent();
+        }
+
+        // problem in db2 : Comparisons between CLOB and CLOB are not supported.
+        // we need do it by casting the Clob to VARCHAR.
+        if (parent != null
+                && (parent instanceof ASTEqual || parent instanceof ASTNotEqual)
+                && dbAttr.getType() == Types.CLOB
+                && parent.getOperandCount() == 2
+                && parent.getOperand(1) instanceof String) {
+            Integer size = parent.getOperand(1).toString().length() + 1;
+
+            out.append("CAST(");
+            super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
+            out.append(" AS VARCHAR(" + size + "))");
+        }
+        else {
+            super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
+        }
+    }
 }



Mime
View raw message