setDistinct() problem

2005-07-14 Thread zcaby29
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()

Re: setDistinct() problem

2005-07-14 Thread Alvaro Coronel
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 cri

Re: setDistinct() problem

2005-07-15 Thread zcaby29
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

Re: setDistinct() problem

2005-07-15 Thread Raphael Mankin
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 [EMAIL PROTECTED] wrote: > > Thanks for the reply Alvaro! > > If I don't use a criterion, I get another extra weird error writt

Re: setDistinct() problem

2005-07-15 Thread Daniel Curto Millet
Thanks for the reply! It now compiles but I still get multiple values. Daniel Quoting Raphael Mankin <[EMAIL PROTECTED]>: > 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-Ju

Re: setDistinct() problem

2005-07-15 Thread Thomas Fischer
Hi, Does your Area table have a primary key ? Consider that for reading the Areas, the Peer reads _ALL_ columns from the Area table, so if e.g. a primary key is read, this leads always to distinct results, so the distinct has no effect at all. You can circumvent this by: 1) manually create a

Re: setDistinct() problem

2005-07-15 Thread Daniel Curto Millet
Thanks for the reply Thomas! Although the table has a primary key, it's not the postcode. I tried the following piece of code following Thomas' route n°2: criteria = new Criteria(); criteria.addSelectColumn("area.postcode"); criteria.add(AreaPeer.POSTCODE, (

Re: setDistinct() problem

2005-07-15 Thread Thomas Fischer
Hi, BasePeer.doSelect gives you a set of village Record objects, whereas AreaPeer.doselect gives you a list of area objects. If you want to use BasePeer.doSelect(), you have to process the village records. Look up the homepage of village in the wiki, get the source code, and see how to proces