Re: delete rule for flatten relationship?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Aug 30 2003 - 21:01:02 EDT

  • Next message: Holger Hoffstätte: "Re: update of many to many"

    Ok, everything I said in the message below is formally correct, with
    one little correction - it is irrelevant :-) ; there is an easy way to
    delete an object on one side of a many-to-many flattened relationship.
    An obvious one that I somehow overlooked. Before doing a delete,
    explicitly remove object from the flattened relationship. This will
    delete a join record:

    a.removeFromRelToB(b);
    context.deleteObject(a);
    context.commitChanges();

    This is it.

    Andrus

    On Wednesday, August 27, 2003, at 06:08 PM, Andrus Adamchik wrote:

    > On Wednesday, August 27, 2003, at 05:19 AM, Tore Halset wrote:
    >> Hello
    >>
    >> A<<-->a_in_b<-->>B are flattened to
    >> A<<-->>B
    >>
    >> What are the best way to delete a A? Deleting the A should delete all
    >> entries in a_in_b for the given A.
    >
    > This situation is indeed not handled by Cayenne. I will open a bug
    > report. Just need to define the right criteria for automatically
    > deleting join records. Any ideas are welcomed (one being an explicit
    > setting of additional delete rule on a flattened relationship).
    >
    > For now delete rules for tables that do not map to an ObjEntity may be
    > specified at the database level. I think even MySQL has some limited
    > support for row delete rules (?)
    >
    >> I have tried with delete rule nullify, but it did not work. I am
    >> afraid
    >> that a cascade (on the A-->>B relation) will delete all B's.
    >
    > Exactly. Delete rule will have no effect on the join table in case of
    > flattened relationships.
    >
    > Andrus
    >
    >



    This archive was generated by hypermail 2.0.0 : Sat Aug 30 2003 - 21:00:34 EDT