Oh no I didn't ...! I just realized that I was using the db attribute
name and not the object name. Can I blame this on my flu?
Bryan, Jurgen, Adam, sorry for wasting your time!
-----Original Message-----
From: Andrus Adamchik [mailto:andru..bjectstyle.org]
Sent: Wednesday, April 06, 2005 8:55 PM
To: cayenne-use..bjectstyle.org
Subject: Re: Testing ExpressionFactory for null values
Hmm... What version of Cayenne do you have? We have this test case
that passes just fine:
public void testEvaluateEQUAL_TONull() throws Exception {
// this line does the same as ExpressionFactory.matchExp()
Expression equalTo = new ASTEqual(new ASTObjPath("artistName"),
null);
Artist match = new Artist();
assertTrue(equalTo.match(match));
Artist noMatch = new Artist();
noMatch.setArtistName("123");
assertFalse("Failed: " + equalTo, equalTo.match(noMatch));
}
Andrus
On Apr 6, 2005, at 10:41 PM, Fredrik Liden wrote:
> I think you ran it as a regular query. I'm trying to do in-memory
> filtering.
> Perhaps that's the difference? I don't think a sql query is generated
> in
> my case.
>
> List entries (is some list)
> Expression exp = ExpressionFactory.matchExp("phoneExtension", null);
> List finalEntries = exp.filterObjects(entries);
>
>
> -----Original Message-----
> From: Bryan Lewis [mailto:brya..aine.rr.com]
> Sent: Wednesday, April 06, 2005 7:33 PM
> To: cayenne-use..bjectstyle.org
> Subject: Re: Testing ExpressionFactory for null values
>
> Really?? I use a matchExp with a null value with no problem. For
> example,
> this gets the employees that have no phone:
>
> Expression exp = ExpressionFactory.matchExp("phoneExtension",
> null);
>
> That generates SQL like:
>
> SELECT t0.* FROM EMPLOYEE t0 WHERE t0.PHONEEXTENSION IS NULL
>
> What SQL do you see in your log?
>
>
>
> ----- Original Message -----
> From: "Fredrik Liden" <flide..ranslate.com>
> To: <cayenne-use..bjectstyle.org>
> Sent: Wednesday, April 06, 2005 9:53 PM
> Subject: RE: Testing ExpressionFactory for null values
>
>
> Hi Bryan,
>
> Expression notNullExp = ExpressionFactory.noMatchExp("attributeName",
> null));
>
> This returns ALL the items in the list. However, I just want to get
the
> list of objects where the attribute is null. When I tried
>
> Expression notNullExp = ExpressionFactory.MatchExp("attributeName",
> null));
>
> I get no hits at all. If anything I can always iterate through the
list
> and do the if else but I thought it would look prettier with the
> filtering. :)
>
> -----Original Message-----
> From: Bryan Lewis [mailto:brya..aine.rr.com]
> Sent: Wednesday, April 06, 2005 6:39 PM
> To: cayenne-use..bjectstyle.org
> Subject: Re: Testing ExpressionFactory for null values
>
> If I understand what you're asking, yes. The ExpressionFactory will
do
> the
> right thing if you give it a value of null.
>
> Expression notNullExp =
> ExpressionFactory.noMatchExp("attributeName",
> null));
>
>
> ----- Original Message -----
> From: "Fredrik Liden" <flide..ranslate.com>
> To: <cayenne-use..bjectstyle.org>
> Sent: Wednesday, April 06, 2005 9:20 PM
> Subject: Testing ExpressionFactory for null values
>
>
> Is it possible to test for null values using the in-memory
> ExpressionFactory?
>
> Or is it just bad design to keep default values as null?
> Does anyone have any input?
>
> Thanks!
>
> Fredrik
>
>
This archive was generated by hypermail 2.0.0 : Thu Apr 07 2005 - 14:32:42 EDT