RE: Testing ExpressionFactory for null values

From: Fredrik Liden (flide..ranslate.com)
Date: Wed Apr 06 2005 - 22:41:06 EDT

  • Next message: Andrus Adamchik: "Re: Testing ExpressionFactory for null values"

    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 : Wed Apr 06 2005 - 22:39:52 EDT