openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Blevins (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-1992) java.lang.ArrayIndexOutOfBoundsException if positional parameter are not started from 1
Date Fri, 13 May 2011 02:25:47 GMT


David Blevins commented on OPENJPA-1992:

So here's what I got.  Perspective of Linda is that "attempting to bind a parameter that did
not correspond to a parameter in the query is intended to cause an exception."  She didn't
comment on how strict we should be with the 1 thing.  Certainly the spec says 1 in no uncertain

I ran a test with Hibernate and EclipseLink and both of them will allow this:

    Query query = entityManager.createQuery("SELECT m from Movie as m WHERE m.title = ?2 AND
m.year = ?4");
    query.setParameter(2, "Foo");
    query.setParameter(4, 2011);
    return query.getResultList();

Both of them will throw an exception from the setParameter method if the index doesn't exist,
but neither cares what numbers you do or don't use beyond that.

So at this point I would just have to say you're in the clear from a letter of the spec perspective,
but in terms of practicality (editing huge queries can take hours and relabeling index continuously
just slows you down) and in compatibility with current EclipseLink and Hibernate implementations
and past OpenJPA versions, it would be great to at least get a vendor specific flag to turn
on/off the strict behavior.

If we had something that could be set at the unit level, that would be a very big help to
us and potentially other users migrating or upgrading.

> java.lang.ArrayIndexOutOfBoundsException if positional parameter are not started from
> ---------------------------------------------------------------------------------------
>                 Key: OPENJPA-1992
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.1.0
>            Reporter: Han Hong Fang
>            Assignee: Michael Dick
>             Fix For: 2.2.0
>         Attachments:, OPENJPA-1992.patch
> Query q = em.createQuery("SELECT x FROM Magazine x WHERE x.title = ?2 and x.price >
> q.setParameter(2, "JDJ").setParameter(3, 25.0);
> When the query is executed, java.lang.ArrayIndexOutOfBoundsException will be thrown.
Since "JDJ" and "25.0" will be stored in arr[0] and arr[1] (when arr.size =2) but the query
execution code tries to get them via arr[2] and arr[3].

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message