db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Eade <se...@backstagetech.com.au>
Subject Re: Retrieving a big list of ids but not a big list of objects
Date Wed, 04 Feb 2004 12:20:39 GMT
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: 

When you create your criteria you will want to do something like:


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();
    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 Eade
Backstage Technologies Pty. Ltd.

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message