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 93B4EC31D for ; Thu, 31 May 2012 01:51:24 +0000 (UTC) Received: (qmail 34528 invoked by uid 500); 31 May 2012 01:51:23 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 34374 invoked by uid 500); 31 May 2012 01:51:23 -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 34227 invoked by uid 99); 31 May 2012 01:51:23 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 May 2012 01:51:23 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id 22F67142859 for ; Thu, 31 May 2012 01:51:23 +0000 (UTC) Date: Thu, 31 May 2012 01:51:23 +0000 (UTC) From: "Heath Thomann (JIRA)" To: dev@openjpa.apache.org Message-ID: <274250262.19916.1338429083145.JavaMail.jiratomcat@issues-vm> In-Reply-To: <826385426.9394.1327961710189.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Closed] (OPENJPA-2118) Prepared SQL query does not handle collection-valued parameter where collection is empty 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-2118?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Heath Thomann closed OPENJPA-2118. ---------------------------------- > Prepared SQL query does not handle collection-valued parameter where collection is empty > ---------------------------------------------------------------------------------------- > > Key: OPENJPA-2118 > URL: https://issues.apache.org/jira/browse/OPENJPA-2118 > Project: OpenJPA > Issue Type: Bug > Components: sql > Affects Versions: 2.0.0, 2.1.0, 2.2.0 > Reporter: Heath Thomann > Assignee: Heath Thomann > Fix For: 2.0.2, 2.1.2, 2.3.0, 2.2.1 > > > In PreparedQueryImpl.setCollectionValuedParameter, we do a '%n' but don't check for n==0, as can be seen here: > private void setCollectionValuedParameter(Map result, > Collection values, int[] indices, Object param) { > int n = values.size(); > Object[] array = values.toArray(); > if (n > indices.length || indices.length%n != 0) { <---------------------line 389 in 2.0.x > When n==0, the following exception will occur: > Exception data: java.lang.ArithmeticException: divide by zero > at org.apache.openjpa.jdbc.kernel.PreparedQueryImpl.setCollectionValuedParameter(PreparedQueryImpl.java:389) > I will upload a test to reproduce this issue and a proposed fix in the next day or two. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira