db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Curto Millet <d.mil...@ucl.ac.uk>
Subject Re: setDistinct() problem
Date Fri, 15 Jul 2005 11:13:43 GMT

Thanks for the reply!

It now compiles but I still get multiple values.

Daniel

Quoting Raphael Mankin <raph@mankin.org.uk>:

> IIRC you have to cast the 2nd argument of add() to Object.I have tripped over
> this one as well. The methods in the class are infelicitously overloaded.
>
>
>
> On 15-Jul-2005 zcaby29@ucl.ac.uk wrote:
> >
> > Thanks for the reply Alvaro!
> >
> > If I don't use a criterion, I get another extra weird error written here
> > below:
> > java.lang.Error: Unresolved compilation problem:
> > The method add(String, Object, SqlEnum) is ambiguous for the type Criteria
> >
> > So it has a problem with:
> > criteria.add(AreaPeer.POSTCODE, "NULL", Criteria.NOT_EQUAL);
> >
> > If anyone has any clues or hints or anything useful, I'd be very thankful,
> >
> > Daniel
> >
> > Quoting Alvaro Coronel <alvarocoronel67@yahoo.com>:
> >
> >> Well... it might have nothing to do with it but for me it is just weird to
> >> use a Criterion there.
> >>
> >> What about this?
> >>
> >> criteria = new Criteria();
> >> criteria.add(AreaPeer.POSTCODE, "NULL", Criteria.NOT_EQUAL);
> >> criteria.setDistinct();
> >>
> >> If this selects distinct, you can go on to adding the order
> >>
> >> criteria.addAscendingOrderByColumn(AreaPeer.POSTCODE)
> >>
> >> Good luck!
> >>
> >> Álvaro.
> >>
> >> zcaby29@ucl.ac.uk wrote:
> >>
> >> 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
> >>
> >>
> >> __________________________________________________
> >> Do You Yahoo!?
> >> Tired of spam?  Yahoo! Mail has the best spam protection around
> >> http://mail.yahoo.com
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
>
> --
>                                Lead us not into temptation; we
>                                can find our own way.
>
>
> Raphael Mankin
> ----------------------------------
>
> ---------------------------------------------------------------------
> 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