Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 7584 invoked from network); 8 Nov 2003 17:26:56 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 8 Nov 2003 17:26:56 -0000 Received: (qmail 81760 invoked by uid 500); 8 Nov 2003 17:26:44 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 81669 invoked by uid 500); 8 Nov 2003 17:26:43 -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 81551 invoked from network); 8 Nov 2003 17:26:42 -0000 Received: from unknown (HELO mail.gmx.net) (213.165.64.20) by daedalus.apache.org with SMTP; 8 Nov 2003 17:26:42 -0000 Received: (qmail 18453 invoked by uid 65534); 8 Nov 2003 17:26:44 -0000 Received: from adsl-62-167-86-10.adslplus.ch (EHLO gmx.ch) (62.167.86.10) by mail.gmx.net (mp001) with SMTP; 08 Nov 2003 18:26:44 +0100 X-Authenticated: #15507884 Message-ID: <3FAD271F.4040502@gmx.ch> Date: Sat, 08 Nov 2003 18:25:51 +0100 From: Jakob Braeuchi User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: OJB Developers List Subject: Re: Columns listed multiple times in select clause References: <3FAC2AE9.80009@x2dev.com> In-Reply-To: <3FAC2AE9.80009@x2dev.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 hi matt, i can not reproduce the behaviour you mentioned in your post. ensureColumns expects a list of attributeNames _not_ dbColumns. please post your query and the resulting sql. jakob Matt Mastrangelo wrote: > 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 > > --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org