Re: deleteObject() and removeFrom*List()

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jun 22 2004 - 12:53:52 EDT

  • Next message: André Luiz do Nascimento Sousa: "Calling CayenneModeller within Eclipse IDE"

    Hi Mike,

    Check out delete rules. You can use a Nullify delete rule for the
    PaperBilling -> Account relationship -
    http://objectstyle.org/cayenne/modelerguide/modeling-object-layer/
    delete-rules.html This should work with read-only entity, as at the
    end we are not updating an Account row (I think this might have been
    the original reason to preserve the "mutator" methods for to-many
    relationships of read-only entities).

    Of course your code example below should work as well.

    Andrus

    On Jun 21, 2004, at 3:27 PM, Mike Kienenberger wrote:
    > I have a situation where I need to delete an object, but it's a member
    > of
    > another object's toMany relationship list.
    >
    > My normal practice would be to modify (or delete) the object, and
    > invalidate
    > the "owner" object, but that's not practical in this case.
    >
    > Can I do something as simple as the following?
    >
    > anAccount.removeFromPaperBillWarningList(aPaperBillWarning);
    > aPaperBillWarning.deleteObject();
    > [...sometime much later...]
    > aDataContext.commitChanges();
    >
    > Account is a read-only entity, although I do have removeFrom*List()
    > methods
    > defined for it.
    >
    > I know that this kind of situation used to cause problems under
    > WebObjects.
    >
    > -Mike



    This archive was generated by hypermail 2.0.0 : Tue Jun 22 2004 - 12:53:57 EDT