Re: Old DataContext hanging around

From: Mike Kienenberger (mkienen..laska.net)
Date: Fri May 20 2005 - 10:40:18 EDT

  • Next message: Alan Guo: "accurate time of Date in SQLTemplate"

    Todd O'Bryan <toddobrya..ac.com> wrote:
    > Is it possible that Cayenne could be caching old objects with their
    > old DataContexts longer than I'd like?
    >
    > Here's the situation:
    >
    > I'm working on a Tapestry application and the user's DataContext is
    > stored in the Visit object. I have a problem where I used
    >
    > Foo aFoo = (Foo) getDataContext().createAndRegisterNewObject(Foo.class);
    >
    > And then I tried
    >
    > bar.setFoo(aFoo);
    >
    > and got an exception that aFoo and bar have different DataContexts.
    >
    > Sure enough, I printed the DataContexts and they are different, but I
    > noticed that every time I crash Tapestry and have to restart the
    > session, I get a new DataContext, but the bar object above keeps an
    > old DataContext from a while ago while the foo gets the correct
    > current DataContext.
    >
    > Is this a problem of caching and if so, is there an easy way to clear
    > the cache when I destroy the Visit?
    >
    > If it's not a problem of caching, does anyone have an idea where I
    > should start looking?

    The first thing I'd try is outputting the value of foo and bar's
    getDataContext() each time you access it.
    Maybe bar's datacontext is being stored in your session, and your session is
    being preserved across crashes?
    One thing you could do is use localObjects to move bar into
    getDataContext().



    This archive was generated by hypermail 2.0.0 : Fri May 20 2005 - 10:38:17 EDT