db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Campbell, Justin" <jcampb...@profilesys.com>
Subject RE: How to select only 1 column from a table?
Date Mon, 31 Mar 2003 15:11:00 GMT
Eric and Richard -- try this instead:

mainProductPeer.doSelectVillageRecords(crit);

This will return a List of Record objects (see:
com.workingdogs.village.Record)

You can then return fields from the Record objects.

Hope this helps.

- Justin

-----Original Message-----
From: Eric Emminger [mailto:eric@ericemminger.com]
Sent: Monday, March 31, 2003 10:07 AM
To: Turbine Torque Users List
Cc: richard@goldmail.net.il
Subject: Re: How to select only 1 column from a table?


Richard

> I try to select only 1 column from a table using the peer object method
DoSelect()
> I've try:
>       Criteria crit = new Criteria();
>       crit.addSelectColumn(mainProductPeer.MAIN_PRODUCT_SEQID);
>       List SeqIDList = mainProductPeer.doSelect(crit);
> 
> I receive an Exception :
>      com.workingdogs.village.DataSetException: Only 1 columns exist!
> 
> Is it possible do this with Torque peer object?

I'm not sure. I've never done this myself. I just tried a similar select 
to try to help you, but it failed as well. I'm guessing that Torque is 
trying to turn the query into a List of *complete* objects, but since 
only one column exists, it fails to set all the properties of the 
objects. I'm going to ask about the intended use of addSelectColumn.

> If not is there another solution ?

I believe the other solution would be to use doSelectVillageRecords 
instead of doSelect. That will return a List of 
com.workingdogs.village.Record. So, to get a List of what you actually 
want, you could do the following.

Criteria crit = new Criteria();
crit.addSelectColumn(mainProductPeer.MAIN_PRODUCT_SEQID);
List villageList = mainProductPeer.doSelectVillageRecords(crit);
List SeqIDList = new Vector();
Iterator it = villageList.iterator();
while (it.hasNext())
{
     SeqIDList.add(new Integer(it.next().getValue(1).asInt()));
}

Note that Village records are 1-based, not 0-based, which is why you use 
getValue(1) instead of getValue(0). Also, the above gives you a List of 
Integer; use whatever you need.

Eric


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