Re: Register DO with DC Multiple Times?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jul 08 2005 - 03:17:00 EDT

  • Next message: Kevin Menard: "Re: Register DO with DC Multiple Times?"

    This is fixed in CVS. I am curious though what exactly in your code
    caused this problem to show up?

    Andrus

    On Jul 8, 2005, at 10:33 AM, Andrus Adamchik wrote:

    > Good catch. Seems like a bug to me. I guess prior to 1.2 it wasn't
    > that visible as there was no auto-registering of related objects.
    > I'll create a test case to verify it and check a fix shortly.
    >
    > Andrus
    >
    >
    > On Jul 8, 2005, at 9:39 AM, Kevin Menard wrote:
    >
    >
    >
    >> Hey all,
    >>
    >> I just spent the last few hours debugging this webapp of mine. Since
    >> it's using Tapestry 4, I thought I had messed up some of the
    >> persistence
    >> stuff or something. Instead, I came across something in Cayenne that
    >> just doesn't seem right.
    >>
    >> If a DO gets registered with a DC twice, it'll attempt to commit
    >> twice.
    >> Since it is the same exact object however, only one PK will be
    >> generated, which causes the commit to fail. Now, I'd certainly agree
    >> that you probably shouldn't try to register twice, but in my case,
    >> the
    >> first registration actually came from setting an already committed
    >> object as relationship parameter. Cayenne is able to auto-
    >> register the
    >> DO that the relationship value is being set on and it does so
    >> transparently, which is cool. However, its side effects are not
    >> transparent.
    >>
    >> My guess is that DataContext#registerNewObject() should consult its
    >> object store before calling registerNewObjectWithEntity(), or the
    >> latter
    >> should perform the check. Or maybe the ObjectStore should use a
    >> HashSet
    >> rather than an ArrayList. I really don't know, but like I said, it
    >> should be transparent.
    >>
    >> Am I correct in this assessment? It is getting rather late here,
    >> so I
    >> may just be delusional . . .
    >>
    >> --
    >> Kevin
    >>



    This archive was generated by hypermail 2.0.0 : Fri Jul 08 2005 - 03:17:07 EDT