Flattened Relationships revisited

From: Andriy Shapochka (ashapochk..otmail.com)
Date: Tue Feb 04 2003 - 05:26:02 EST

  • Next message: Andriy Shapochka: "Re: Stored Procedure Support"

    I started to implement support of flattened relationships in CommitContext and, in the process, a couple of probably important questions to the current implementation have arisen.
    Let's say we have:
    ObjEntity A;
    ObjEntity B;
    flattened ObjRelationship AtoB;
    flattened reverse ObjRelationship BtoA;
    DataObject a; of type A
    DataObject b; of type B

    Scenario:
    1) a.addToManyTarget("AtoB", b, true);
    2) b.removeToManyTarget("BtoA", a, true);
    3) b.addToManyTarget("BtoA", a, true);

    After these three actions we must have had exactly one registered flattened relationship between 'a' and 'b' in the data context, since setReverse == true.
    But it looks like the current implementation does not unregister flattenedInsert in the data context after 2). And then 3) registers the relationship between 'a' and 'b' once more. As a result the following commit will try to insert two identical records into the intermediate relating table. What do everybody think? We could try and deal with this problem at commit-time but I think this behavior is inconsistent by itself. If so maybe I should try to rewrite the registration/unregistration code.

    One more thing, if setReverse == false in addToManyTarget a flattened relationship does not get registered in the data context and as a result the consequent commit does not insert a record into the table-intermediary that is the relationship is not saved in the database at all. Am I correct? This also seems to be inconsistent.

    Andriy.



    This archive was generated by hypermail 2.0.0 : Tue Feb 04 2003 - 05:48:53 EST