Re: how to create this Expression

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue May 11 2004 - 12:35:46 EDT

  • Next message: Andrus Adamchik: "Re: Object hierarchy on a single link table."

    On May 11, 2004, at 8:58 AM, Tore Halset wrote:

    > Hello!
    >
    > I have two enities A, and B with a flattened many to many
    > relationship. I want to query for all A's that has at least one
    > related B.
    >
    > Something like this:
    > Expression qual = Expression.fromString("not bArray.empty");
    > new SelectQuery(A.class, qual);
    >
    > Is it possible? How?
    >
    > Regards,
    > - Tore.

    It was suggested to implement such qualifier some time ago by Giulio
    Cesare Solaroli. It hasn't been done yet, though I like the idea very
    much.

    For now you can use a hack to force an inner join over the relationship
    that will effectively filter out all A's that have no B's. E.g.

    // use a relationship with condition that always evaluates to true
    // this will force a join
    Expression qual = Expression.fromString("db:bArray.id != null");

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue May 11 2004 - 12:35:39 EDT