[
https://issues.apache.org/jira/browse/OPENJPA-1992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13030170#comment-13030170
]
Pinaki Poddar commented on OPENJPA-1992:
----------------------------------------
The binding parameter indexing, ordering and naming are somewhat sensitive to
many implicit assumptions throughout our codebase. It is made more sensitive
after we introduced Prepared Query Caches that rebinds parameters (that
originally could have been named) to SQL (that only accepts integral
parameter). The index of parameters affects the kernel and also note that
kernel internals can insert its own parameters that are invisible to the user
application.
Please be careful with a change unless it is broken for regular, spec-compliant
use case. If for example we allow numeric parameters *not* to begin with 1 and
be monotonic and continuous, nothing stops a user to specific "SELECT a FROM A
a where a.name=?100234 and A.something=?34562" -- it will get real hairy to
support such an innovative user :)
An informative error message when integral parameters violate *any* of the
following
a) start with 1
b) monotonic
c) continuous
is all that is required to keep life simple, code uncomplicated and majority of
user satisfied.
> java.lang.ArrayIndexOutOfBoundsException if positional parameter are not
> started from 1
> ---------------------------------------------------------------------------------------
>
> Key: OPENJPA-1992
> URL: https://issues.apache.org/jira/browse/OPENJPA-1992
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.1.0
> Reporter: Han Hong Fang
> Assignee: Michael Dick
> Attachments: Main.java, OPENJPA-1992.patch
>
>
> Query q = em.createQuery("SELECT x FROM Magazine x WHERE x.title = ?2 and
> x.price > ?3");
> 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: http://www.atlassian.com/software/jira