Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ABEA141FD for ; Fri, 13 May 2011 14:47:27 +0000 (UTC) Received: (qmail 23129 invoked by uid 500); 13 May 2011 14:47:27 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 23053 invoked by uid 500); 13 May 2011 14:47:27 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 23045 invoked by uid 99); 13 May 2011 14:47:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 May 2011 14:47:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 May 2011 14:47:26 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 660538872F for ; Fri, 13 May 2011 14:46:47 +0000 (UTC) Date: Fri, 13 May 2011 14:46:47 +0000 (UTC) From: "Michael Dick (JIRA)" To: dev@openjpa.apache.org Message-ID: <785840089.10254.1305298007414.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2116946973.21298.1304502123094.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (OPENJPA-1992) java.lang.ArrayIndexOutOfBoundsException if positional parameter are not started from 1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENJPA-1992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13033063#comment-13033063 ] Michael Dick commented on OPENJPA-1992: --------------------------------------- I'd be fine with opening a new improvement to allow this, and if there is sufficient interest we'd look into it. Pinaki's point about the prepared SQL cache is particularly concerning (for me at least). I suspect any changes we make in this area will affect the cache as well. In the current implementation (and probably in previous releases) this sort of query will not work as expected (beyond the ArrayIndex exception). It's just my personal opinion, but I think it's unlikely that there will be many queries that use positional parameters and do not already start at one. I suspect most of those are copy / paste jobs from JDBC prepared statements which do start at 1. Those that aren't copied or pasted from existing statements would probably prefer the named parameter support (which is more friendly anyway). I could be all wet here though - and I can see where it would be a real pain if you had to go back and update the positional args. > 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 > Fix For: 2.2.0 > > 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