db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: setDistinct() does not work?
Date Wed, 07 Sep 2005 13:38:55 GMT




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" <bouvetkons@statnett.no> 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


Mime
View raw message