Object relationships and Visit

From: Reinier Mostert (rendie..labo.co.za)
Date: Tue Jun 08 2004 - 16:35:19 EDT

  • Next message: Bill Dudney: "Re: optimistic locking?"

    Hi All,

    I use Cayenne with Tapestry. First some background: in the constructor
    of my Tapestry Visit, I do:
    dataContext =
    Configuration.getSharedConfiguration().getDomain().createDataContext();

    This dataContext is then retrieved everywhere I need access to Cayenne.
    I assumed that when I do this the dataContext spans the whole session.

    When I started using this (eons ago), I got problems when I do a commit
    (some exception about the object being registered with a different
    dataContext). I mailed on this list and the Tapestry list, and received
    replies to the effect that this was an artifact of the new way Tapestry
    3 operates and how it stores items in the HTTPSession.

    I then started passing record keys around, and added a method to every
    Cayenne class that returns the key. I have a dataFactory that takes a
    key and returns a Cayenne Data object (using registeredObject).

    Now the problem: I'm using object relationships, and when I add rows to
    a one to many on one page, and try to read the list on another page,
    they're not in sync. On each page I get the dataContext from the visit.
    I've started resolving that by using addPrefetch to refresh the object
    and the relationships, but it is not very elegant.

    A recent post by Andrus (Re: Cayenne Article on TheServerSide.com) makes
    me think that this is all unneccessary.

    Can anybody share on how they pass objects between pages (or their
    related classes), and how I should be going about having a datacontext
    that spans the session and makes object relationships work?

    Thanks in advance
    reinier

    PS My wife just had a baby, so my access to the list will be somewhat
    sporadic in the next few days.



    This archive was generated by hypermail 2.0.0 : Tue Jun 08 2004 - 16:36:15 EDT