Re: Using dataobject from a DataContext in other DataContext

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Nov 21 2003 - 20:15:45 EST

  • Next message: Leonardo R. Nunes: "Violation of PRIMARY KEY constraint"

    On Nov 21, 2003, at 5:50 PM, Leonardo R. Nunes wrote:
    > I'm thinking in keep one kind of global DataContext to provide queries.
    > Is this a good practice?

    As briefly mentioned in the user guide chapter here:

    http://objectstyle.org/cayenne/userguide/datactxt/moving-objects.html

    it is a good practice for "static" and/or read-only data, e.g. lookup
    tables (say a list of countries, or a list of user types in the
    system). Otherwise it is much more practical to assign each user
    session its own DataContext.

    Andrus

    > -----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 - 20:15:50 EST