You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Oliver Gierke (JIRA)" <ji...@apache.org> on 2016/05/27 12:25:12 UTC

[jira] [Commented] (OPENJPA-2018) Cannot bind String[] to ParameterExpression for path.in(parameter)

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

Oliver Gierke commented on OPENJPA-2018:
----------------------------------------

I'd like to remove the workaround we have in Spring Data JPA for this bug. Should we reopen this one or create a new ticket? See my comment above from two years ago.

> 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: Mark Struberg
>              Labels: binding, criteria_api, jpa
>             Fix For: 2.3.0
>
>         Attachments: OPENJPA-2018-test-update.patch, OPENJPA-2018-test2.patch, OPENJPA-2018-with-array.patch, OPENJPA-2018.patch, missingpatch.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.3.4#6332)