Re: Please help: retrieval and proper usage of per thread DataContext

From: Joshua Pyle (joshua.t.pyl..mail.com)
Date: Wed Nov 30 2005 - 12:37:57 EST

  • Next message: Joseph Hannon: "Re: Please help: retrieval and proper usage of per thread DataContext"

    True, If I store something in session scope then I use "Transfer
    Objects". But the DataContext will live so long as ther cayenne
    object does, it retains a reference to the datacontext that created
    it. you could actually get the DataContext from the cayenn object
    itself even though I would frown on this.

    On 11/30/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > This will work only if
    >
    > (a) you use it consistently and there is no other code that sticks
    > a DataContext in a session and
    > (b) you app carries no Cayenne-related state between requests (such
    > as session DataObjects).
    >
    > I believe this was not the case in Joseph's app, judging from the
    > problems that he had.
    >
    > Andrus
    >
    >
    > On Nov 30, 2005, at 7:46 PM, Joshua Pyle wrote:
    > > Just incase this helps, this is all I do when getting a datacontext.
    > >
    > > public DataContext getDataContext() {
    > > DataContext context = null;
    > > try {
    > > context = DataContext.getThreadDataContext();
    > > } catch (IllegalStateException ex) {
    > > // Bind the DataContext
    > > context = DataContext.createDataContext();
    > > DataContext.bindThreadDataContext(context);
    > > }
    > > return context;
    > > }
    > >
    > > This is working great and essentially just gives me a DataContext that
    > > lives only during the request. I've found this is a great aproach for
    > > web based applications.
    > >
    > > --
    > > Joshua T. Pyle
    > > Go has always existed.
    >
    >

    --
    Joshua T. Pyle
    Go has always existed.
    



    This archive was generated by hypermail 2.0.0 : Wed Nov 30 2005 - 12:37:58 EST