Re: Filter a to-many relationship

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jul 08 2004 - 10:36:27 EDT

  • Next message: Kevin J. Menard, Jr.: "IllegalArgumentException"

    A solution suggested by Joe (if I understand it correctly) is to
    override getStuff() to perform a custom query instead of relying on
    automatic relationship resolution.

    This will work, however keep in mind that unlike regular relationship,
    such implementation will not cache the results, so each invocation will
    make a trip to the DB. A way to improve it is to use "local cache"
    setting on such query. Result caching was introduced just recently
    (http://objectstyle.org/cayenne/userguide/fetch/result-caching.html)
    and seems to be ideal in your situation (hmm... that's the first time
    I've thought of such use of caching... should add it to the FAQ I
    guess).

    Cheers
    Andrus

    On Jul 8, 2004, at 9:04 AM, McDaniel, Joe R. wrote:
    > Joris,
    >
    > One way is to move the query down to the getStuff object level. I
    > initially thought I should start "at the top" of my object tree but
    > found that starting lower allowed me to do the query up still and gain
    > better control over the local objects and its children. This really
    > achieves most of the desired results for me and creates a complex
    > query.
    > Using the preload methods can help, too.
    >
    > You can also create a view in the database.
    >
    > I have not figured out how to create a view with the GUI tool, but that
    > should be an option.
    >
    > You can also do a generalized query with the macro language (some
    > examples are on the list in response to my own questions).
    >
    > Best,
    >
    > Joe



    This archive was generated by hypermail 2.0.0 : Thu Jul 08 2004 - 10:36:31 EDT