I've not used ExpressionFactory (I tend to stick to just Expression),
but you do have the option with an Expression when supplying a map to
omit parameters and it'll drop those out of the query. For example:
"foo = $foo and bar = $bar"
If you only supply $foo, your query will become "foo = $foo" (it'll omit
the bar query). There is an option to control this and I suspect your
issue is closely related to this feature, but if I'm wrong someone will
correct me. :-)
Actually, that brings me to the question ... Why not just use an
Expression?
final Expression expression =
Expression.fromString("username = $username and password =
$password");
Map map = new HashMap(2);
map.put("username", username);
map.put("password", password);
SelectQuery query = new SelectQuery(User.class,
expression.expWithParameters(map));
Of course, yours does look tighter. :-) I'm not sure which is fastest.
/dev/mrg
-----Original Message-----
From: Erik Hatcher [mailto:eri..hatchersolutions.com]
Sent: Friday, April 29, 2005 1:29 PM
To: cayenne-use..bjectstyle.org
Subject: missing property, but no error
I wrote code like this:
Expression expression = ExpressionFactory.matchExp("username",
username);
expression.andExp(ExpressionFactory.matchExp("password",
password));
SelectQuery query = new SelectQuery(User.class, expression);
But I had not yet modeled the "password" attribute, or even the DB
column. Yet this code executed fine with no errors at all. Why is
that? Shouldn't I have gotten an error?
Thanks,
Erik
This archive was generated by hypermail 2.0.0 : Fri Apr 29 2005 - 13:51:11 EDT