From torque-user-return-6417-apmail-db-torque-user-archive=db.apache.org@db.apache.org Wed Sep 07 13:39:10 2005 Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 70118 invoked from network); 7 Sep 2005 13:39:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Sep 2005 13:39:09 -0000 Received: (qmail 71843 invoked by uid 500); 7 Sep 2005 13:39:05 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 71791 invoked by uid 500); 7 Sep 2005 13:39:04 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 71289 invoked by uid 99); 7 Sep 2005 13:38:59 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2005 06:38:59 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [194.175.229.106] (HELO mail.seitenbau.net) (194.175.229.106) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Sep 2005 06:39:10 -0700 Received: from [195.127.188.18] (helo=www.seitenbau.net) by router1.seitenbau.net with esmtp (Exim 4.43) id 1ED08d-0002wd-9f for torque-user@db.apache.org; Wed, 07 Sep 2005 15:38:55 +0200 In-Reply-To: Subject: Re: setDistinct() does not work? To: "Apache Torque Users List" X-Mailer: Lotus Notes Release 6.5 September 26, 2003 Message-ID: From: Thomas Fischer Date: Wed, 7 Sep 2005 15:38:55 +0200 X-MIMETrack: Serialize by Router on www/seitenbau(Release 6.5.1|January 21, 2004) at 07.09.2005 03:38:54 PM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, you are falling into a common pit here. The problem is not with setDistinct() not working, the problem is that you are not taking the words "may not be complete or applicable" literally :-) StationLinesPeer.doSelect() adds all the columns of the Stationlines to the select columns of the criteria, so the "distinct" is not only on UPPER(station_lines.ID_TEXT), but also on all other columns. This typically leads to all StationLines Records being different. Print the criteria after calling StationLinesPeer.doSelect(crit) to get the query Torque actually uses. Thomas "Bouvet Konsulent" schrieb am 07.09.2005 15:16:25: > hello, > I am running Torque 3.1 together with Oracle 8.1.7. I have the > following method > > protected void populateStationDropdown(DropdownForm form) { > Criteria crit = new Criteria(); > crit.add(StationLinesPeer.STATION_FLAG, STATION_FLAG_STASJONER); > crit.addAscendingOrderByColumn(StationLinesPeer.ID_TEXT); > crit.setDistinct(); > logger.debug("populateStationDropdown. Crit="+crit); > try { > form.setStationsDropdown(StationLinesPeer.doSelect(crit)); > } catch (TorqueException e) { > logger.error(e); > } > } > > > the following debug-message is written to the log: > > 2005-09-07 14:52:41,284 DEBUG [webapp.struts.DropdownAction] > populateStationDropdown. Crit=Criteria:: station_lines. > STATION_FLAG<=>station_lines.STATION_FLAG='S': Current Query SQL > (may not be complete or applicable): SELECT DISTINCT > UPPER(station_lines.ID_TEXT) FROM station_lines WHERE station_lines. > STATION_FLAG='S' ORDER BY UPPER(station_lines.ID_TEXT) ASC > > when I run the above SQL directly towards the database, I get all > distinct ID_TEXT: ...Agdenes, Ajaure, AJ4.... > when I run the SQL through Torque, I do not get distinct ID_TEXT, > instead: : ...Agdenes, Ajaure, Ajaure, AJ4.... > > how come? > > cheers, > pj > > > > > > > > Statnett SF, Tel. head office +47 22527000, Enterprise No. NO 962 > 986 633 VAT, www.statnett.no, firmapost@statnett.no > _________________________________________________________________ > > This e-mail and any attached files are confidential and may be > legally privileged. If you have received this transmission in error > please notify the sender by reply e-mail immediately and then delete > the e-mail. > E-mail transmission cannot be guaranteed to be secure or error free > as information could be intercepted, corrupted, lost, destroyed, > arrive late or incomplete. If verification is required please > request a hard copy version. This e-mail message has been virus > checked by the virus programs used by Statnett SF. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org > For additional commands, e-mail: torque-user-help@db.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org