openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mprud...@apache.org
Subject svn commit: r486429 - /incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java
Date Wed, 13 Dec 2006 00:26:48 GMT
Author: mprudhom
Date: Tue Dec 12 16:26:47 2006
New Revision: 486429

URL: http://svn.apache.org/viewvc?view=rev&rev=486429
Log:
Wrap non-Collection arguments in Collections so that the query language can support having
both varargs "in" clauses as well as clauses that take a Collection parameter.

Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java?view=diff&rev=486429&r1=486428&r2=486429
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java
Tue Dec 12 16:26:47 2006
@@ -17,6 +17,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -178,7 +179,14 @@
      * Return the collection to test for containment with.
      */
     protected Collection getCollection(ExpContext ctx, ExpState state) {
-        return (Collection) _const.getValue(ctx, state);
+        Object val = _const.getValue(ctx, state);
+
+        // wrap non-Collection parameters in a Collections so the query
+        // lanuage can permit varargs "in" clauses
+        if (!(val instanceof Collection))
+            val = Collections.singleton(val);
+
+        return (Collection) val;
     }
 
     public void acceptVisit(ExpressionVisitor visitor) {



Mime
View raw message