You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Catalina Wei (JIRA)" <ji...@apache.org> on 2009/01/29 18:58:59 UTC

[jira] Resolved: (OPENJPA-865) JPA2 Query support for collection-valued input parameters in IN Expression predicate

     [ https://issues.apache.org/jira/browse/OPENJPA-865?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Catalina Wei resolved OPENJPA-865.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0

code checked in under trunk svn r738940

> JPA2 Query support for collection-valued input parameters in IN Expression predicate
> ------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-865
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-865
>             Project: OpenJPA
>          Issue Type: Sub-task
>            Reporter: Catalina Wei
>            Assignee: Catalina Wei
>             Fix For: 2.0.0
>
>
> Support for collection-valued parameters in JPA2 Spec in 
> considering the followoing query:
>    select e from CompUser e where e.age in (10, 20, 30)
> when using input parameters for each in-item,  the query would rewrite to:
>   select e from CompUser e where e.age in (?1, ?2, ?3)
> each in-item contains a single value.
> JPA2 syntax allows in-item in the in-expression predicate to contain multiple values such that the above query can be :
>      select e from CompUser e where e.age in ?1
>    
> or
>    
>     select e from CompUser e where e.age in :ages
>   the parameters in these 2 queries contain more than 1 value, the caller on Query interface will do something like the following:
> // first create collection that holds values for the parameters
>    Collection ages = new ArrayList();
>    ages.add(10);
>    ages.add(20);
>    ages.add(30);
> // issue query using new syntax and passing collection valued parameter
>    List rs = em.createQuery("select e from CompUser e where e.age in :ages").setParameter("ages", ages).getResultList();
> Note that when collection valued parameter is used, the in-item is not enclosed in parenthesis;
>    the following query would only allow :ages to contain a single value:
>        
>     select e from CompUser e where e.age in (:ages)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.