From dev-return-5569-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Wed Aug 15 19:15:59 2007 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 84336 invoked from network); 15 Aug 2007 19:15:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Aug 2007 19:15:55 -0000 Received: (qmail 91234 invoked by uid 500); 15 Aug 2007 19:15:53 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 91085 invoked by uid 500); 15 Aug 2007 19:15:53 -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 91075 invoked by uid 99); 15 Aug 2007 19:15:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2007 12:15:52 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Aug 2007 19:16:09 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B5C267141E2 for ; Wed, 15 Aug 2007 12:15:30 -0700 (PDT) Message-ID: <28394741.1187205330727.JavaMail.jira@brutus> Date: Wed, 15 Aug 2007 12:15:30 -0700 (PDT) From: "Daniel Lee (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Commented: (OPENJPA-312) derby fails with duplicate primary key(s) in group by list In-Reply-To: <8026787.1186710222542.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12520068 ] Daniel Lee commented on OPENJPA-312: ------------------------------------ Per discussion conclusion, attached here is the patch of fix using a ListArray to keep track of the columns in _grouping. StringTokenizer has been removed. Thanks, Daniel > derby fails with duplicate primary key(s) in group by list > ---------------------------------------------------------- > > Key: OPENJPA-312 > URL: https://issues.apache.org/jira/browse/OPENJPA-312 > Project: OpenJPA > Issue Type: Bug > Components: sql > Affects Versions: 1.0.0 > Reporter: Daniel Lee > Assignee: Daniel Lee > Priority: Minor > Fix For: 1.0.0 > > Attachments: OPENJPA-312.patch, OPENJPA-312.patch > > > derby fails with duplicate primary key(s) in group by list > With query "select o.customer, avg(o.amount) from Order o group by o.customer" the push-down query contains duplicate columns in the group by clause. This is okay when DB2 and other DB that tolerate the duplicates but Derby returns error. > Of course, we can ask fix on Derby but we can also easy fix in OpenJPA to avoid duplicates in the group by list. Please refer to the following for the error result and the attach patch for the fix. > Output from running the query that generate duplicate in the group by list: > 6429 demo TRACE [main] openjpa.Query - Executing query: select o.customer, avg(o.amount) from Order o group by o.customer > 6639 demo TRACE [main] openjpa.jdbc.SQL - executing prepstmnt 1405375428 SELECT t1.countryCode, t1.id, t1.version, t1.city, t1.state, t1.street, t1.zip, t1.creditRating, t1.name, AVG(t0.amount) FROM Order t0 INNER JOIN Customer t1 ON t0.customer_countryCode = t1.countryCode AND t0.customer_id = t1.id GROUP BY t1.countryCode, t1.id, t1.version, t1.countryCode, t1.id, t1.city, t1.state, t1.street, t1.zip, t1.countryCode, t1.id, t1.creditRating, t1.name -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.