openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Curtis (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2018) Cannot bind String[] to ParameterExpression for path.in(parameter)
Date Wed, 23 Oct 2013 19:41:54 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13803216#comment-13803216
] 

Rick Curtis commented on OPENJPA-2018:
--------------------------------------

My only comment on the patch is in regards to the unit test. For future reference, don't use
openjpa.RuntimeUnenhancedClasses. That is a very buggy feature and we really should be discouraging
usage of it. Also try to follow the test case pattern outlined by SingleEMTestCase / SingleEMFTestCase.
This way you'll get enhancement for free, and the test will work across all of the different
supported databases.

> Cannot bind String[] to ParameterExpression for path.in(parameter)
> ------------------------------------------------------------------
>
>                 Key: OPENJPA-2018
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2018
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.0
>            Reporter: Oliver Gierke
>            Assignee: Michael Dick
>              Labels: binding, criteria_api, jpa
>         Attachments: OPENJPA-2018.patch, openjpa-2018.zip
>
>
> Given the following code:
> {code}
> User user = new User("Dave", "Matthews", "foo@bar.de");
> em.persist(user);
> em.flush();
> CriteriaBuilder builder = em.getCriteriaBuilder();
> CriteriaQuery<User> criteria = builder.createQuery(User.class);
> Root<User> root = criteria.from(User.class);
> criteria.where(root.get("firstname").in(builder.parameter(String[].class)));
> TypedQuery<User> query = em.createQuery(criteria);
> for (ParameterExpression parameter : criteria.getParameters()) {
>   query.setParameter(parameter, new String[] {"Dave", "Carter"});
> }
> List<User> result = query.getResultList();
> assertThat(result.isEmpty(), is(false));
> {code}
> I get a
> {code}
> <openjpa-2.0.0-r422266:935683 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
The specified parameter of type "class [Ljava.lang.String;" is not a valid query parameter.
> {code}
> Using {{Collection}} as {{ParameterExpression}} type and binding the parameters via {{Arrays.asList(...)}}
works fine.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message