Re: Unique persistent object and caching issue

From: Laurent Marchal (lmarcha..maeur.com)
Date: Tue Jul 15 2008 - 11:10:20 EDT

  • Next message: Andrus Adamchik: "Re: Unique persistent object and caching issue"

    the query.addPrefetch("relatedArtistAux") does not work for me !

    In fact it does a little because the Artist_AUX list is well in sync
    with the database.
    But now each time i use the Artist object Cayenne do 1 request for each
    related Artist_AUX row !
    That was the thing i wanted to avoid....

    I attached the logs, where Artist is dbo.SNAME and Artist_AUX is
    dbo.SNAME_AUX.

    Is there a way to fix that ?

    Andrus Adamchik wrote:
    >
    > On Jul 15, 2008, at 4:49 PM, Laurent Marchal wrote:
    >
    >> But the thing I don't understand is why when i refetch the Artist
    >> object the relationships are not invalidated.
    >
    > By default only the object itself is refreshed. Cayenne has no way of
    > knowing which part of the object graph has changed, so this is
    > something a user must tell it.
    >
    >> Is Cayenne considering that the relationships of Artist are still
    >> good even if the Artist snapshot version changed ?
    >> Must i do a RefreshQuery for each of my SelectQueries to be sure the
    >> data in cayenne correspond to the database ?
    >
    > No. You need to use prefetching on this relationship in the
    > SelectQuery, and then the related list will be fetched and refreshed
    > together with the root object.
    >
    > query.addPrefetch("gelatedArtistAux");
    >
    > Andrus
    >
    >
    >
    >


    --- will run 2 queries.
     --- transaction started.
     SELECT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 WHERE t0.SKDID = ? [bind: 1->SKDID:29]
     === returned 1 row. - took 32 ms.
     SELECT t0.SAFC, t0.SKDID, t0.SAVALUE, t0.SASEQNO FROM dbo.SNAME_AUX t0 JOIN dbo.SNAME t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? [bind: 1->SKDID:29]
     === returned 8 rows. - took 32 ms.
     +++ transaction committed.

     --- will run 1 query.
     --- transaction started.
     SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:0]
     === returned 1 row. - took 31 ms.
     +++ transaction committed.

     --- will run 1 query.
     --- transaction started.
     SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:105]
     === returned 1 row. - took 31 ms.
     +++ transaction committed.

     --- will run 1 query.
     --- transaction started.
     SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:106]
     === returned 1 row. - took 12 ms.
     +++ transaction committed.

     --- will run 1 query.
     --- transaction started.
     SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:107]
     === returned 1 row. - took 12 ms.
     +++ transaction committed.

     --- will run 1 query.
     --- transaction started.
     SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:109]
     === returned 1 row. - took 12 ms.
     +++ transaction committed.

     --- will run 1 query.
     --- transaction started.
     SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:111]
     === returned 1 row. - took 31 ms.
     +++ transaction committed.

    --- will run 1 query.
    --- transaction started.
    SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:112]
    === returned 1 row. - took 27 ms.
    +++ transaction committed.

    --- will run 1 query.
    --- transaction started.
    SELECT DISTINCT t0.SKDID, t0.SKDSAM, t0.SKDNAME, t0.SKDSTART, t0.SKDWKDAYS FROM dbo.SNAME t0 JOIN dbo.SNAME_AUX t1 ON (t0.SKDID = t1.SKDID) WHERE t1.SKDID = ? AND t1.SASEQNO = ? AND t1.SAFC = ? [bind: 1->SKDID:29, 2->SASEQNO:1, 3->SAFC:113]
    === returned 1 row. - took 32 ms.
    +++ transaction committed.



    This archive was generated by hypermail 2.0.0 : Tue Jul 15 2008 - 11:11:26 EDT