db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ricardo Lecheta" <ricardolech...@brturbo.com>
Subject SELECT TABLE.FIELD FROM TABLE. How do I do this?
Date Fri, 11 Apr 2003 04:57:26 GMT
This is my table:

CREATE TABLE PESSOA
(
id INTEGER NOT NULL,
nome VARCHAR (50) NOT NULL,
fone VARCHAR (50) NOT NULL,
PRIMARY KEY(id)
);

I would like to do a sql statement like the following one:

SELECT TABLE.FIELD FROM TABLE // only a field of the table

but I can´t.

I tried to do it like this:

Criteria c = new Criteria();
c.addSelectColumn(PessoaPeer.NOME);
PessoaPeer.doSelect(c);

SQL Statement generated by Torque: Current Query SQL (may not be complete or applicable):
SELECT PESSOA.NOME FROM PESSOA

the sql statement is correct, but the following mistake occurs:
com.workingdogs.village.DataSetException: Bad conversion: java.lang.NumberFormatException:
For input string: "Ricardo"

I have noticed that this is happening because Torque doesn´t understand I want to select
only one field of the table.

So, on method populateObject(...) of BasePessoaPeer Class, Torque tries to recuperate fields
that didn´t appear on my research.

try{

obj.setId(row.getValue(offset + 0).asInt());   // INVALID TYPECAST, this field doesn´t exist
in my query.
obj.setNome(row.getValue(offset + 1).asString());
obj.setFone(row.getValue(offset + 2).asString());
}

catch (DataSetException e){

throw new TorqueException(e); // THIS EXCPETION IS RAISED

}

Could you please tell me the right way to do it ?

Thank you

Ricardo.



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message