Re: Flushing new/dirty Objects before Query

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Nov 20 2003 - 13:15:11 EST

  • Next message: Andrus Adamchik: "Re: strange one-to-one relationship"

    [Moving this to cayenne-user]

    On Nov 20, 2003, at 8:49 AM, Fehlhammer, Manuel wrote:

    > Hi,
    >
    > Why aren't dirty objects of DataContext flushed to the db, when I
    > start a new Query?
    > Writing to the database seems to occur only with
    > DataContext.commitChanges().
    > So if I want to see changed/ new data in my current DataContext I have
    > to commit all changes - not what I want, because I can not rollback
    > anymore....
    >
    > Any hints?
    >
    > Manuel
    >

    Hi Manuel,

    > Writing to the database seems to occur only with
    > DataContext.commitChanges().

    Correct, this is the expected behavior.

    > So if I want to see changed/ new data in my current DataContext I have
    > to commit all changes - not what I want, because I can not rollback
    > anymore....

    If you perform a query and it brings back some of the objects that you
    have already modified but haven't committed, Cayenne will merge DB
    changes with your object changes (never overwriting any of your
    changes). If there is an unmodified cached object in the DataContext,
    it is fully refreshed using new DB data. This is very reasonable
    behavior, I guess it should suit your needs.

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Nov 20 2003 - 13:15:15 EST