Felipe Ramos wrote:
> I'm working with Torque 3.1 and I need to catch a List of ids of a
> table of customers ( I only need their ids). That table can have
> thousands of rows, and each row has a lot of columns, so using
> Criteria to catch a list of thousands of customer objects is very
> inefficient and very, very, slow. I only need the ids of a query
> like this "select id from customer where money>500" .
>
> How can I develop a method that execute that query and return only a
> list of ids without having to retrieve a list of objects?
> Which is the best solution?
Take a look at the Criteria howto:
http://db.apache.org/torque/criteria-howto.html
When you create your criteria you will want to do something like:
criteria.addSelectColumn(CustomerPeer.CUSTOMER_ID);
This will tell the criteria to select only the one column.
You would then use BasePeer.doSelect(criteria) to execute the query and
then retrieve the ids from the list using an Iterator and:
Integer customerId = row.getValue(1).asIntegerObj();
or
int customerId = row.getValue(1).asInt();
But I would have to query exactly what you are going to do with this
large list of Ids. I guess I am showing my bias towards webapps where
this would be a fairly uncommon thing to do.
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
|