Re: Expression help

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Sun Jan 10 2010 - 07:08:58 EST

  • Next message: Andrus Adamchik: "Re: Expression help"

    Or you can use left joins:
    ExpressionFactory.matchExp("paintingsArray+.color",
    null).orExp(ExpressionFactory.matchExp("paintingsArray+.color", blue));

    2010/1/10 Andrus Adamchik <andru..bjectstyle.org>

    > This requires Cayenne 3.0 and EJBQLQuery with subquery. Something like this
    > might work:
    >
    > new EJBQLQuery(
    > "SELECT a FROM Artist a " +
    > "WHERE NOT EXISTS " +
    > "(SELECT p FROM Painting p WHERE p.color <> 'XYZ')";
    >
    > Andrus
    >
    >
    > On Jan 7, 2010, at 2:32 AM, Mark Fraser wrote:
    >
    > Suppose I have an Artists table and a Paintings table with the usual setup
    >> of the Artist class having a PAINTINGS_ARRAY property. Suppose further
    >> that
    >> the painting has a "color" property that can be a string or null.
    >>
    >> How would I build an Expression such that I get back the Artists that have
    >> either no paintings or only paintings with a specific color value (or a
    >> null
    >> color value)?
    >>
    >> I am using Cayenne 2.0.4 in case that matters.
    >>
    >> TIA
    >>
    >
    >

    -- 
    Andrey
    



    This archive was generated by hypermail 2.0.0 : Sun Jan 10 2010 - 07:09:49 EST