Of course. Probably the easiest way is to use one of the Expression
methods:
Expression expression = Expression.fromString("paintingTitle =
$paintingTitle");
Map parameters = new HashMap();
parameters.put("paintingTitle", "Daisy Verve");
SelectQuery query = new SelectQuery(Painting.class,
expression.expWithParameters(parameters));
List paintings = dataContext.performQuery(query);
If you are actually wanting to limit the number of columns coming back,
look at SQLTemplate in section 7.6 of the manual. You won't get
DataObjects coming back, though, just raw data rows.
/dev/mrg
-----Original Message-----
From: Williams, Beth [mailto:beth.william..FIB.ORG]
Sent: Thursday, October 21, 2004 5:32 PM
To: cayenne-use..bjectstyle.org
Subject: Query certain attributes
I have just started working with Cayenne and have a pretty basic
question related to querying. Is there a way to only query certain
attributes from a db table. From the examples I've seen so far
(SelectQuery query = new SelectQuery(Artist.class);) all attributes are
returned; equivalent to a SELECT * FROM xxx_table;. Is it possible (and
if so, how) to query only certain attributes; equivalent to SELECT
painting_title, estimated_price FROM painting;.
Hope that makes sense. Thanks.
Beth
This archive was generated by hypermail 2.0.0 : Thu Oct 21 2004 - 17:46:27 EDT