From 148d8f8df2969cc4a57347f3128c682f2491c1b4 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 13 Dec 2006 00:26:47 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@486429 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/openjpa/jdbc/kernel/exps/InExpression.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java index e63493e09..b752071d4 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java @@ -17,6 +17,7 @@ package org.apache.openjpa.jdbc.kernel.exps; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.Map; @@ -178,7 +179,14 @@ class InExpression * 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) {