TS,
This is a little complicated to answer because you don't say how you'll
use the data. In practice, I never use the "||" operator in a program
because it's just as easy to add the strings together later. So...
If I were programming this and had to do the simplest thing, I would do
the following:
List theContacts = ContactPeer.doSelect(new Criteria());
Iterator iter = theContacts.iterator();
while (iter.hasNext())
{
Contact contact = (Contact)iter.next();
String displayField=contact.firstName+" "+contact.lastName;
// do whatever you want with DisplayField
}
Another approach might be to write a function in the Contact object
called "getDisplayField".
Finally, it might be that you really only want these two columns
returned (for performance reasons perhaps? I'm not sure the performance
gain is substantial, though. Is contact a big table?)
In that case, you'd have to use the "addSelectColumn" function in the
Criteria object, and then use the BasePeer to execute the query, and
then use the Village Record object to get the datafields.
HTH
-Peter
On Fri, 2002-10-25 at 15:13, [EMAIL PROTECTED] wrote:
>
> I have the following sql query
>
> String sql = "select contact_id, first_name||' '||last_name as
> display_field from contact"
>
> how do I represent this using Criteria?
> thanks
> TS
>
>
> --
> To unsubscribe, e-mail: <mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: <mailto:turbine-torque-user-help@;jakarta.apache.org>
>
--
To unsubscribe, e-mail: <mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-torque-user-help@;jakarta.apache.org>