[
https://issues.apache.org/jira/browse/OPENJPA-865?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Catalina Wei updated OPENJPA-865:
---------------------------------
Description:
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)
Summary: JPA2 Query support for collection-valued input parameters in
IN Expression predicate (was: JPA2 Query support for collection-valued input
parameters)
> 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
>
> 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.