Re: caching problem ?

From: Lothar Krenzien (lkrenzie..eb.de)
Date: Wed Mar 15 2006 - 09:55:21 EST

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

    That's right. But objectB should only be generated if objectA exists. And because B needs some informations from A I tried to re-read objectA before I create B. But I think I will now rework my app so that I pass the required informations as paramter.

    But to get it clear for me : At the moment I have the following code:

    public mainMethod1() {
     objectA = getObjectABack()
     ...
    }

    public mainMethod2() {
      firstMethod()
      secondMethod()
    }

    private firstMethod() {
     objectA = getObjectABack()
     if (objectA == null ) {
       context.createAndRegisterObject(ObjectA.class)
       // do somethink with objectA
     }
    }

    private secondMethod() {
     objectA = getObjectABack()
     if (objectA != null) {
       context.createAndRegisterObject(ObjectB.class)
     // do somethink with objectB
     }
    }

    private ObjectA getObjectABack() {
     query = new SelectQuery(ObjectA.class)
     ...
     query.setCachePolicy ....
     return context.performQuery....
    }

    The context object is always the same, but the method getObjectABack() return always null regardless of the CachePolicy (cayenne 1.2 M11). I thought that all created objects are available through the context object ? Please note that the method getobjectABack() is called multiple times within the same transaction. Could that be the reason ?

    Thanks for patience
    Lothar

    > -----Ursprüngliche Nachricht-----
    > Von: cayenne-use..bjectstyle.org
    > Gesendet: 15.03.06 15:29:42
    > An: <cayenne-use..bjectstyle.org>
    > Betreff: Re: caching problem ?

    > So you create an objectA and objectB and commitChanges() did i get you know?
    >
    >
    > ----- Original Message -----
    > From: "Lothar Krenzien" <lkrenzie..eb.de>
    > To: <cayenne-use..bjectstyle.org>
    > Sent: Wednesday, March 15, 2006 1:03 PM
    > Subject: 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 - 09:55:24 EST