RE: Removing from object graph

From: Cris Daniluk (cris.danilu..laraview.com)
Date: Tue Feb 01 2005 - 17:40:26 EST

  • Next message: Andrus Adamchik: "Re: Removing from object graph"

    iter.remove() should work fine if its invoked before the deleteObject()
    call, though I think a better general solution would be to deprecate
    deleteObject(DataObject) and use deleteObjects(Collection), as was done with
    invalidateObjects, unregisterObjects, localObjects, etc in 1.1. This still
    requires the list copy, but at least deleteObjects isolates the user from
    that.

    Cris

    > -----Original Message-----
    > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > Sent: Tuesday, February 01, 2005 4:24 PM
    > To: cayenne-use..bjectstyle.org
    > Subject: RE: Removing from object graph
    >
    > IMO making sure that iter.remove()/context.deleteObject()
    > works properly in all cases makes more sense, and will be
    > more in line with the [strange though "standard"] ways of
    > Java Collections API.
    >
    > Andrus
    >
    >
    >
    > > I actually just set the relationship to nullify, as I
    > thought it was
    > > already, but I'm still having the CME unless I clone the
    > list as you
    > > suggest. That seems a little funky to me... Is it feasible
    > to switch
    > > that to a collection type that supports concurrent
    > modification, like
    > > a vector?
    > >
    > > Cris
    > >
    > >> -----Original Message-----
    > >> From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > >> Sent: Tuesday, February 01, 2005 3:57 PM
    > >> To: cayenne-use..bjectstyle.org
    > >> Subject: Re: Removing from object graph
    > >>
    > >> Cris,
    > >>
    > >> Cloning an array before iterating over it would do the
    > trick (leave
    > >> the rest of the code unchaged):
    > >>
    > >> List tempList = new
    > ArrayList(document.getDocumentWorkflowArray());
    > >> Iterator workflowIter = tempList.iterator();
    > >>
    > >> To make it even simpler than that you can set delete rule for
    > >> relationship from DocumentWorkflow to Document to "nullify" in the
    > >> modeler. In this case you won't need
    > >> "removeFromDocumentWorkflowArray" line as it will happen
    > >> automatically (you'd still need to iterate over a copy of the
    > >> relationship list).
    > >>
    > >> And finally using iter.remove() in combination with
    > >> context.deleteObject()
    > >> should also work, though I haven't tested it myself.
    > >>
    > >> Andrus
    > >>
    >
    >
    >
    >





    This archive was generated by hypermail 2.0.0 : Tue Feb 01 2005 - 17:40:27 EST