Re: 1-to-many relationships do not update on new query

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Sep 03 2004 - 10:12:19 EDT

  • Next message: Claudio Rosati: "What means???"

    Hi Peter,

    Does this happen in different DataContexts in the same JVM? Cayenne
    should handle this case, but there is still some room for mistake when
    automatic refresh can't be done properly. If you have any more details
    on that, I'd appreciate it (e.g. is there Object2.getObject1()
    relationship?).

    To explicitly deal with this problem you can use prefetching in the
    query, e.g.:

    query.addPrefetch("object2s");

    Also, as far as cache policies are concerned, they are not related to
    this case. Cache policies deal with caching *lists* of objects, not the
    objects themselves.

    Andrus

    On Sep 2, 2004, at 9:37 AM, Peter Backx wrote:
    > I'm currently using Cayenne (1.1B2) with MySQL for a 3 table database
    > with a few relationships. The database itself is changed by different
    > programs concurrently and when I try to update the view in one program
    > it works ok for basic objects, however if objects were added to a
    > 1-to-many relationship these don't seem to be updated.
    >
    > Maybe to make it more clear: I have Object1 that has a 1-to-many
    > relationship with Object2. If I get Object1 through a query the first
    > time everything works ok and Object1.getObject2s() works fine. However
    > if new Object2's are added to that relationship (from another
    > thread/program/DataContext) and I perform a new query to get Object1 I
    > still get the old list of Object2's. So I don't see the newly added
    > relationships.
    >
    > I thought that maybe caching was used but executing the following
    > before querries does not help:
    > context.getObjectStore().getDataRowCache().clear();
    > also setting the NO_CACHE policy on the queries does not help.
    >
    > This looks like it could be a FAQ but I couldn't find anything, so any
    > help would be greatly appreciated.
    >
    >
    > regards,
    > Peter



    This archive was generated by hypermail 2.0.0 : Fri Sep 03 2004 - 10:12:27 EDT