Actually Peer selects the entire row if you use doSelect(Criteria) and
not call addSelectColumns in the Criteria. See the code below:
public static Vector doSelectVillageRecords( Criteria criteria )
throws Exception
{
criteria.setDbName(mapBuilder.getDatabaseMap().getName());
if (criteria.getSelectColumns().size() == 0)
{
addSelectColumns ( criteria );
}
.....
Since I call addSelectColumns in the Criteria, Peer will not add all
columns. That explains why Peer didn't add any columns. But in
populateObject method, Peer will convert all columns into objects. I
guess that's why I got the exception. Actually I like the feature that I
can add individual columns instead of whole row. The fix will be in the
populateObject method, i.e according to selected column to convert to
the corresponding fields. I will submit a patch when I figure this out.
Howard Lin
> -----Original Message-----
> From: John McNally [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 27, 2001 6:19 PM
> To: [EMAIL PROTECTED]
> Subject: Re: exception when selecting one column using Criteria
>
>
> That is an odd error, but if you are using torque generated peers
> (BarPeer), it is going to add all 5 columns and not expect the one you
> added to be there. You will end up with an Exception in the
> Peer after
> you figure out this one. Except that it seems BarPeer did not add any
> columns, hmmm.
>
>
> Peers select the entire row. So many people want it otherwise yet no
> one ever provides a solution. It has not been a big deal to
> me, but it
> would be a nice feature, if you wish to be the one to add it.
>
> john mcnally
>
> Howard Lin wrote:
> >
> > I want to select one column ('foo') from a table ('bar')
> which has five
> > columns. The SQL is:
> > SELECT bar.foo from bar.
> >
> > So I have the following:
> >
> > Criteria c = new Criteria();
> > c.addSelectColumn(BarPeer.FOO);
> > BarPeer.doSelect(c);
> >
> > The SQL generated by Criteria is what I want but I got the following
> > exception:
> >
> > com.workingdogs.village.DataSetException: Only 1 columns exist!
> > at com.workingdogs.village.Record.getValue(Record.java:546)
> > at BaseBarPeer.populateObject(BaseBarPeer.java:165)
> > at BaseBarPeer.row2Object(BaseBarPeer.java:146)
> > at BaseBarPeer.populateObjects(BaseBarPeer.java:238)
> > at BaseBarPeer.doSelect(BaseBarPeer.java:174)
> >
> > I'm using Oracle 8i and the column is not a primary key. It
> seems like
> > it's a village problem. But I couldn't find anything from village's
> > mailing list. Thanks in advance,
> >
> > Howard Lin
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]