db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zcab...@ucl.ac.uk
Subject setDistinct() problem
Date Thu, 14 Jul 2005 17:23:34 GMT

Hi,

I have a very strange problem with Torque. I'm building a website using struts
where on a certain page, a form is populated by having access to the database
(MySql) using Torque. So in my ActionForm, I have the following to populate an
option collection.

            criteria = new Criteria();

            // No postcode with a null value
            Criteria.Criterion notNullPost = criteria.getNewCriterion
                      (AreaPeer.POSTCODE, "NULL", Criteria.NOT_EQUAL);
            criteria.add(notNullPost);

            // Order the list
            criteria.addAscendingOrderByColumn(AreaPeer.POSTCODE);

            // Show only distinct
            criteria.setDistinct();

            System.out.println(criteria.toString());

            List post = AreaPeer.doSelect(criteria);
            request.getSession().setAttribute("add_postcode_letters", post);

The problem is that the list I get on the page is a list with multiple values as
if the setDistinct() wouldn't have worked.

Yet, when I query the database from the MySql command line using the query I got
from this bit of code: System.out.println(criteria.toString());
It works under MySql... Here's the sql query:
mysql> SELECT DISTINCT area.POSTCODE FROM area WHERE area.POSTCODE<>'NULL' ORDER
 BY area.POSTCODE ASC;

The table is called area and has 5 columns including the postcode column.
I'm using Torque 3.1, Tomcat v5 and MySql v4.1

If anyone has any clues or hints or anything useful, I'd be very thankful,

Daniel


---------------------------------------------------------------------
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