Re: performQuery generics

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Dec 26 2007 - 09:56:21 EST

  • Next message: Michael Gentry: "Re: Cayenne XML Names"

    Hi Mike,

    Hope you feeling better now.

    To mention a related thing, Cayenne actually supports an expression
    format that includes the root entity in the expression itself. That
    would be EJBQL, and it is much more loaded...

    Andrus

    On Dec 26, 2007, at 4:29 PM, Mike Kienenberger wrote:

    > On Dec 25, 2007 9:14 PM, Aristedes Maniatis <ar..sh.com.au> wrote:
    >> I have to confess to not quite understanding the boundaries between
    >> Expression and Query. 99% of the times that it is used, a Query is
    >> just an Expression with Ordering and a root entity. But I don't
    >> understand why that root entity isn't part of the Expression itself -
    >> does an expression have much meaning without a root entity? It is
    >> always implied within the Expression, since you can't create an
    >> expression which is meaningful for Artist.class and then create a new
    >> SelectQuery(Painting.class).
    >
    > Yes, you can!
    >
    > Consider this:
    >
    > select artist where artist_name = 'bob'
    > select painting p, artist a where p.artist_id = a.id and artist_name
    > = 'bob'
    >
    > The expression is the same for both -- only the object path is
    > different.
    >
    > Expression e = ExpressionFactory.matchExp(String pathSpec, "bob");
    >
    > where
    >
    > String pathSpec = Artist.ARTIST_NAME_PROPERTY;
    > or
    > String pathSpec = Painting.ARTIST_PROPERTY + "." +
    > Artist.ARTIST_NAME_PROPERTY;
    >
    > Note also, that the pastSpec has the same suffix -- all you need to do
    > is adjust the prefix to account for a different root:
    >
    > String pathSpec = rootPathSpecPrefix + Artist.ARTIST_NAME_PROPERTY;
    >
    > where
    >
    > rootPathSpecPrefix = "" for Artist, Painting.ARTIST_PROPERTY + "." for
    > painting, Gallery.PAINTING_LIST_PROPERTY + "." +
    > Painting.ARTIST_PROPERTY + "." for gallery.
    >



    This archive was generated by hypermail 2.0.0 : Wed Dec 26 2007 - 09:56:55 EST