Daryl,
Yes, you can use IN expression and collection valued parameter in JPQL.
In JPA2 spec , JPQL syntax allows collection valued parameter in IN
Expression.
Here is an example:
        Collection params = new ArrayList(2);
        params.add("linux");
        params.add("pc");
        query = "select u from CompUser u where lower(u.computerName) in
?1";
        rs = em.createQuery(query).setParameter(1, params).getResultList();

The SQL where clause looks like this:
    for Derby or DB2:
        WHERE (LOWER(CAST(t0.compName AS VARCHAR(1000))) IN (?, ?))
[params=?, ?]
    for Oracle:
         WHERE (LOWER(t0.compName) IN (?, ?))

Catalina Wei

On Thu, Jun 17, 2010 at 5:13 AM, Daryl Stultz <[email protected]>wrote:

> On Thu, Jun 17, 2010 at 7:58 AM, gilbertoca <[email protected]> wrote:
>
> >
> > I think this[1] reference can help.
> >
> > The examples for these functions all use "=" as the operator. I need
> "IN".
> I don't think there is any problem with my usage of lower() as this works:
>
> select o from User as o where
> lower(o.userCode) = 'ab' or lower(o.userCode) = 'cd'
>
> Do I have to iterate over my collection and build this up with OR or is
> there a way to do this with IN?
>
> --
> Daryl Stultz
> _____________________________________
> 6 Degrees Software and Consulting, Inc.
> http://www.6degrees.com
> http://www.opentempo.com
> mailto:[email protected]
>

Reply via email to