RE: Using dataobject from a DataContext in other DataContext

From: Leonardo R. Nunes (leonard..umersoft.com)
Date: Fri Nov 21 2003 - 17:50:46 EST

  • Next message: Andrus Adamchik: "Re: Using dataobject from a DataContext in other DataContext"

    I'm thinking in keep one kind of global DataContext to provide queries.
    Is this a good practice?

    Thanks!
    Leonardo.

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: sexta-feira, 21 de novembro de 2003 16:32
    To: cayenne-use..bjectstyle.org
    Subject: Re: Using dataobject from a DataContext in other DataContext

    On Nov 21, 2003, at 3:21 PM, Leonardo R. Nunes wrote:

    > Is that not allowed ? I'm getting my dataObject from one DataContex
    > and trying to delete my dataObject in other DataContext.
    >
    > In the example bellow the delete doesn't work.

    Correct - DataObject is tied to just one DataContext for its lifecycle,

    thus allowing independent modifications of data by multiple users (each

    DataContext gets its own independent copy of object). If you have a
    reason to transfer objects between DataContexts, use
    DataContext.localObjects() method:

    http://objectstyle.org/cayenne/userguide/datactxt/moving-objects.html
    http://objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/
    access/DataContext.html#localObjects(java.util.List)

    This method is available in Cayenne since version 1.0.3

    Cheers
    Andrus



    This archive was generated by hypermail 2.0.0 : Fri Nov 21 2003 - 16:47:35 EST