db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Vandahl ...@apache.org>
Subject Re: Getting all entries in one column
Date Wed, 11 Jul 2007 20:30:28 GMT
croniccoder wrote:
> Criteria c = new Criteria();
> c.addSelectColumn(AccountPeer.ACCOUNTNUMBER);
> List list = AccountPeer.doSelect(c);
> But this is throwing and exception, and I'm not sure why. Any ideas??
> com.workingdogs.village.DataSetException: Only 1 columns exist!

I guess your Account table has more than this one column? The
BaseAccountPeer methods try to create a real Account object from your
result set which fails because there are more fields to set than columns
are available in the result set. Two solutions:

1. Remove the line c.addSelectColumn(AccountPeer.ACCOUNTNUMBER); Torque
will select all columns it requires and you will get nice, shiny Account
objects in your list

2. Use BasePeer.doSelect(c) This will return a list of Records and you
can query the value you want like record.getValue(1).asInt()
This approach is slightly faster but actually not really Torque-like.
Nevertheless we all have used this method by some means or other.

Bye, Thomas.

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

View raw message