Re: caching problem ?

From: Lothar Krenzien (lkrenzie..eb.de)
Date: Wed Mar 15 2006 - 08:15:29 EST

  • Next message: Tomas Jucius: "bug in objectId generation?"

    I've just tried out the different caching options described in the user guide but didn't get success :

                    SelectQuery query = (new SelectQuery( ... ;
                    query.addOrdering("packageDate", true);
                    query.setCachePolicy(GenericSelectQuery.LOCAL_CACHE);
                    query.setName("xxxx");

    First I've tried setting
                    query.setRefreshingObjects(false);
    But then the query is executed once and the subsequent calls returns the result of the first execution ( 0 rows instead of 1 row).

    Then I've tried
                query.setRefreshingObjects(true);
    Now it seems that the query is executed on every time against the database. And because the transactions isn't commit at this point the query returns 0 rows instead of the 1 row inserted in the first step ?

    So what I'm dowing wrong ? I want to read data I've just inserted but not yet commited.

    Lothar

    > -----Ursprüngliche Nachricht-----
    > Von: cayenne-use..bjectstyle.org
    > Gesendet: 15.03.06 13:04:04
    > An: cayenne-use..bjectstyle.org
    > Betreff: Re: caching problem ?

    > Because I create a new object there's nothing I can change. And all of my objects are in the same DC. But as I wrote in my first post for me it looks like that cayenne tries to get the objects from database instead of using the cache. And because the transaction isn't committed the data can't be found. I forgot to say that I'm using a datetime parameter as condition in the select query. Could that cause the problem ?
    >
    >
    > > -----Ursprüngliche Nachricht-----
    > > Von: cayenne-use..bjectstyle.org
    > > Gesendet: 15.03.06 12:44:26
    > > An: <cayenne-use..bjectstyle.org>
    > > Betreff: Re: caching problem ?
    >
    >
    > > Hello,
    > > I am not really sure if Cayenne commits the changes as Atomic unit but first
    > > i would check this.
    > >
    > > So, Your problem is you want to be sure that changes in tableA as well as
    > > tableB must be written or none.
    > >
    > > usually this should do the job:
    > > Change object from tableA,
    > > Change object from tableB,
    > > DataContext.commitChanges(); // You must be sure the changes from obejctA,
    > > objectB are in the same DC.
    > > // maybe another constellation would also work. however. ...
    > >
    > > Cayanne "would" keep the changes in sync, All or nothing.
    > > Did you try this?
    > >
    > >
    > > Of course what you explained should work anyway, i cant see any problem in
    > > write/read/write sequence.
    > >
    > > Sako.
    > > ----- Original Message -----
    > > From: "Lothar Krenzien" <lkrenzie..eb.de>
    > > To: <cayenne-use..bjectstyle.org>
    > > Sent: Wednesday, March 15, 2006 12:18 PM
    > > Subject: caching problem ?
    > >
    > >
    > > > Hi ,
    > > >
    > > > I've notified a problem which I don't really understand.
    > > >
    > > > I'm doing an insert into tableA, read from tableA and insert the data into
    > > tableB. Because I want to save all or nothing I commit the transaction after
    > > the last insert. But it looks like that insert data in tableA are not found
    > > after the insert because the data in tableB were not inserted. In the
    > > logfile I can see that the select don't return any data. When I commit the
    > > transaction after inserting into tableA it seems to work. But that's not
    > > what I want. So could it be a caching problem ? And I get no error from the
    > > database.
    > > >
    > > > Here's an example of what I want to do:
    > > >
    > > > insert into tableA
    > > > read from tableA
    > > > insert the just read data into tableB
    > > > commit
    > > >
    > > > cayenne 1.2 M10 + MSSQL 2000 + jtds
    > > >
    > > > Thanks, Lothar
    > > >
    > > > P.S: I've just read about caching in the cayenne user guide
    > > (http://www.objectstyle.org/cayenne/userguide/fetch/result-caching.html). I
    > > there a way to set the caching policy once for all queries ? In the cayenne
    > > modeler the option 'Use shared cache' is set for the used domain node.
    > > > ______________________________________________________________________
    > > > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
    > > > Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130
    > > >
    > > >
    > >
    >
    >
    > ______________________________________________________________
    > Verschicken Sie romantische, coole und witzige Bilder per SMS!
    > Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
    >

    ______________________________________________________________
    Verschicken Sie romantische, coole und witzige Bilder per SMS!
    Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193



    This archive was generated by hypermail 2.0.0 : Wed Mar 15 2006 - 08:15:31 EST