Re: How to model many-to-many relationship with self?

From: James A. Hillyerd (jame..illyerd.com)
Date: Fri Dec 10 2004 - 13:21:29 EST

  • Next message: Gentry, Michael \(Contractor\): "RE: Is it possible to compare entity keys in an object query?"

    Andrus Adamchik wrote:
    > James,
    >
    > I tried your mapping in the Modeler and I don't seem to have any problems,
    > regardless of whether I have "NodeMap" in the model or not. Are you having
    > trouble with this panel?
    >
    > http://objectstyle.org/cayenne/images/modelerguide/objrelationship-path-selection.jpg
    >

    You're right, I played with the modeler some more, and deleting
    "NodeMap" has no direct effect. I think what happened is seeing the
    "Target" column blank on the "Relationships" tab, prompted me to set it
    to Node and then click the "Edit Relationship" button. In that case,
    the modeler tries to find a DbRelationship path from node to node on
    it's own. If you change the target while in the "ObjRelationship
    Inspector" window, it simply clears the DbRelationship list.

    Once I realized that the "DbRelationships" grid is actually full of drop
    downs, I was able to build the relationship. Before I thought I had to
    click on one of the "New" buttons, which was confusing.

    > One thing I noticed (this should show up as a validation message on save)
    > is that node_map has no PK defined. You need to check both columns as PK
    > as "childNodeMapArray" and "parentNodeMapArray" relationships as "To Dep
    > PK".
    >

    Thanks. I don't recall seeing any validation errors for that, but I did
    update my model as node_map definitely should have a PK.

    I guess the only question I have left is... Using this model, I create
    two Node objects (call them nodeA and nodeB). If I add nodeB to
    nodeA's childNodeArray, will nodeA automatically show up in nodeB's
    parentNodeArray?

    Thanks.

    -james

    -- 
    James A. Hillyerd <jame..illyerd.com>
    Java Software Engineer - ActiveRain.com
    



    This archive was generated by hypermail 2.0.0 : Fri Dec 10 2004 - 13:21:34 EST