If you only want to select on one column you can't use the doSelect methods that were 
generated for you
because those try to turn the result into a data object, which is impossible with only 
one column. Look at the
source code for your Peer class to see what I mean.

You have to use the BasePeer class like this:

Criteria c = new Criteria();

c.addSelectColumn(Table1Peer.COLUMN1);
c.setDistinct();

List records = BasePeer.doSelect(c);
List results = new ArrayList();

for (int i = 0; i < records.size(); i++) {
  results.add( ((Record) records.get(i)).getValue(1).asBigDecimal() );
}

return results;

Age


> -----Original Message-----
> From: Vidakovic Aleksandar [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 06, 2001 11:10
> To: [EMAIL PROTECTED]
> Subject: Re: Group By with Criteria
>
>
> Maybe I should precise my question...
>
> what I want:
> I'd like to select only one column with id-numbers. The numbers in that
> column are not unique. I need a distinct set of these id-numbers to
> traverse them ONLY ONE time for each id.
>
> what I did:
>
> I tried it with the following code:
>
>            Criteria criteria = new Criteria();
>            criteria.addSelectColumn( Table1Peer.COLUMN1 );
>            criteria.setDistinct();
>
>            Vector results = Table1Peer.doSelect(criteria);
>
> what I get:
>
> is the following exception from village:
> com.workingdogs.village.DataSetException: Only 1 columns exist!
>
> thanks,
>
> Aleks
>
>
> Santosh Thakur wrote:
>
> >hi,
> >     what u want to achieve from this type clause? Group by we r doing
> >for group functions like sum, avg..
> >I think u want common data of Column1. Then u can use DISTINCT clause of
> >Criteria like Criteria.DISTINCT
> >Santosh
> >
> >
> >
> >
> >>-----Original Message-----
> >>From:       Vidakovic Aleksandar [SMTP:[EMAIL PROTECTED]]
> >>Sent:       Friday, July 06, 2001 11:34 AM
> >>To: [EMAIL PROTECTED]
> >>Subject:    Group By with Criteria
> >>
> >>Salut folks,
> >>
> >>I'm desparately trying to create a Query like "SELECT COLUMN1 FROM
> >>TABLE1 GROUP BY COLUMN1" with Turbine's Criteria class.
> >>
> >>1. How do I add the "GROUP BY" clause?
> >>2. Why am I getting following Exception from village:
> >>com.workingdogs.village.DataSetException: Only 1 columns exist!
> >>
> >>Am I missing something here???
> >>
> >>Thanks in advance,
> >>
> >>Aleks
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to