Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 35961 invoked from network); 7 Nov 2003 23:29:54 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 7 Nov 2003 23:29:54 -0000 Received: (qmail 42974 invoked by uid 500); 7 Nov 2003 23:29:39 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 42946 invoked by uid 500); 7 Nov 2003 23:29:39 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 42933 invoked from network); 7 Nov 2003 23:29:39 -0000 Received: from unknown (HELO out003.verizon.net) (206.46.170.103) by daedalus.apache.org with SMTP; 7 Nov 2003 23:29:39 -0000 Received: from x2dev.com ([68.162.219.26]) by out003.verizon.net (InterMail vM.5.01.05.33 201-253-122-126-133-20030313) with ESMTP id <20031107232946.IXSE1420.out003.verizon.net@x2dev.com> for ; Fri, 7 Nov 2003 17:29:46 -0600 Message-ID: <3FAC2AE9.80009@x2dev.com> Date: Fri, 07 Nov 2003 18:29:45 -0500 From: Matt Mastrangelo User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030901 Thunderbird/0.2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: ojb-dev@db.apache.org Subject: Columns listed multiple times in select clause Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Authentication-Info: Submitted using SMTP AUTH at out003.verizon.net from [68.162.219.26] at Fri, 7 Nov 2003 17:29:45 -0600 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hello, I'm having a problem with a SQL statement returned by a call to org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl#getPreparedSelectStatement(...). The SELECT statement returned lists all the columns referenced in the ORDER BY clause twice in the SELECT clause. Here is what appears to be the causing the problem: In org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement#getStatement(), ensureColumns is called if the query contains an ORDER BY or GROUP BY clause. The ensureColumns method attempts to make sure that any fields referenced in an ORDER BY or GROUP BY are included in the SELECT clause. A list of class attribute names retrieved by a call to appendListOfColumnsForSelect is passed to ensureColumns. The problem seems to be that ensureColumns is expecting a list of database column names, not class attribute names. It checks the list to see if the field in the ORDER BY/GROUP BY exists, and if not, it adds it to the SELECT clause. But because the list contains attribute names and not database column names, none of the fields are found in the passed list. Hence, all fields in ORDER BY/GROUP BY clauses are being appended to the SELECT clause, even if they are already present. This causes problems in some databases, such as Microsoft SQL Server, where the same field cannot be present more than once in the SELECT clause. This doesn't cause a problem in other databases, such as Interbase/Firebird, that allow columns to appear multiple times. Has this problem been reported before, and if so, are there any known workarounds? Thanks for your help. Matt Mastrangelo --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org