mirror of https://github.com/apache/openjpa.git
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
This commit is contained in:
parent
74589c8ae1
commit
148d8f8df2
|
@ -17,6 +17,7 @@ package org.apache.openjpa.jdbc.kernel.exps;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -178,7 +179,14 @@ class InExpression
|
||||||
* Return the collection to test for containment with.
|
* Return the collection to test for containment with.
|
||||||
*/
|
*/
|
||||||
protected Collection getCollection(ExpContext ctx, ExpState state) {
|
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) {
|
public void acceptVisit(ExpressionVisitor visitor) {
|
||||||
|
|
Loading…
Reference in New Issue