You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Ludwig Magnusson <lu...@itcatapult.com> on 2010/01/04 13:34:03 UTC
Get results as ints
Hi!
I would like to select all ids from a table (with a certain criteria). If I
use addSelectColumn on my criteria and do BasePeer.doSelect(criteria), I
only get the columns that I want but they are in form of record objects. Can
I get a list of ints, strings or whatever or do I need to convert the list
myself?
/Ludwig
RE: Antwort: Get results as ints
Posted by Sheldon Ross <sr...@simmgene.com>.
List<Record> records = BaseIdPeer.doSelectVillageRecords(criteria);
List<String> cols = new ArrayList<String>();
Iterator<Record> iter = records.iterator();
while(iter.hasNext()){
cols.add(String.valueOf(iter.next().getValue(1)));
}
return cols;
That's how I do it.
Ross
}
On Mon, 2010-01-04 at 13:55 +0100, Ludwig Magnusson wrote:
> Yes there is a method like that.
> I'll use it then.
> /Ludwig
>
> -----Original Message-----
> From: Thomas Fischer [mailto:fischer@seitenbau.net]
> Sent: den 4 januari 2010 13:47
> To: Apache Torque Users List
> Subject: Antwort: Get results as ints
>
> > I would like to select all ids from a table (with a certain criteria). If
> I
> > use addSelectColumn on my criteria and do BasePeer.doSelect(criteria), I
> > only get the columns that I want but they are in form of record objects.
> Can
> > I get a list of ints, strings or whatever or do I need to convert the
> list
> > myself?
>
> Currently, you need to convert the results yourself. It is not that
> problematic, see the generated peer code as an example. If I remember
> correctly, the record object contains value objects which have an asInt
> method, but the code is more reliable than my memory.
>
> Thomas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
RE: Antwort: Get results as ints
Posted by Ludwig Magnusson <lu...@itcatapult.com>.
Yes there is a method like that.
I'll use it then.
/Ludwig
-----Original Message-----
From: Thomas Fischer [mailto:fischer@seitenbau.net]
Sent: den 4 januari 2010 13:47
To: Apache Torque Users List
Subject: Antwort: Get results as ints
> I would like to select all ids from a table (with a certain criteria). If
I
> use addSelectColumn on my criteria and do BasePeer.doSelect(criteria), I
> only get the columns that I want but they are in form of record objects.
Can
> I get a list of ints, strings or whatever or do I need to convert the
list
> myself?
Currently, you need to convert the results yourself. It is not that
problematic, see the generated peer code as an example. If I remember
correctly, the record object contains value objects which have an asInt
method, but the code is more reliable than my memory.
Thomas
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Antwort: Get results as ints
Posted by Thomas Fischer <fi...@seitenbau.net>.
> I would like to select all ids from a table (with a certain criteria). If
I
> use addSelectColumn on my criteria and do BasePeer.doSelect(criteria), I
> only get the columns that I want but they are in form of record objects.
Can
> I get a list of ints, strings or whatever or do I need to convert the
list
> myself?
Currently, you need to convert the results yourself. It is not that
problematic, see the generated peer code as an example. If I remember
correctly, the record object contains value objects which have an asInt
method, but the code is more reliable than my memory.
Thomas
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org