Removing from object graph

From: Cris Daniluk (cris.danilu..laraview.com)
Date: Tue Feb 01 2005 - 15:38:21 EST

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

    Hi,

    I'm having a little confusion determining the proper way to delete
    DataObjects through a relationship. I have a Document object which has a
    series of dependent DocumentWorkflow objects in a relationship. I am trying
    to delete them as follows:

            Iterator workflowIter =
    document.getDocumentWorkflowArray().iterator();
            while (workflowIter.hasNext()) {
                DocumentWorkflow docWorkflow = (DocumentWorkflow)
    workflowIter.next();
                document.removeFromDocumentWorkflowArray(docWorkflow);
                context.deleteObject(docWorkflow);
            }

    This not surprisingly generates a ConcurrentModificationException. Just
    calling context.deleteObject removes them from the database, but does not
    update the Document object graph, which leads to Fault errors when accessing
    the getDocumentWorkflowArray property later on.

    Likewise, using a DeleteQuery does not update the Document object graph. I
    can't invalidate the Document, because it has changes which must be
    processed in the same transaction.

    Is it safe to call iter.remove() instead of removeFromDocumentWorkflowArray,
    which calls removeToManyTarget? If not, how can I reliably remove all
    objects in a given relationship?

    Thanks!

    Cris



    This archive was generated by hypermail 2.0.0 : Tue Feb 01 2005 - 15:37:54 EST