Hierarchical relationship problems

From: Filip Balas (fbala..mail.com)
Date: Thu Apr 21 2005 - 18:34:40 EDT

  • Next message: Fredrik Liden: "Track changes of a dataobjects property"

    I'm not sure if this has already been covered as
    there doesn't seem to be a search facility for the
    mailing list.

    My problem is that I have a simple hierarchy with
    locations. A location can have child locations and
    vice verca can have a parent:

    Schema:
    --------------
    id
    parent_id
    description

    Now I have modeled this relationship and the modeler
    generated the following:

    <db-entity name="IMV_locations" schema="dbo" catalog="GPSForecast">
     <db-attribute name="description" type="VARCHAR" length="75"/>
     <db-attribute name="id" type="INTEGER" isPrimaryKey="true"
    isMandatory="true" length="10"/>
     <db-attribute name="parent_id" type="INTEGER" length="10"/>
    </db-entity>

    <db-relationship name="rel_children" source="IMV_locations"
    target="IMV_locations" toMany="true">
     <db-attribute-pair source="id" target="parent_id"/>
    </db-relationship>

    <db-relationship name="rel_parent" source="IMV_locations"
    target="IMV_locations" toMany="false">
     <db-attribute-pair source="parent_id" target="id"/>
    </db-relationship>

    <obj-relationship name="children" source="Location" target="Location"
    deleteRule="Cascade"
    db-relationship-path="rel_children.rel_children"/>

    <obj-relationship name="parent" source="Location" target="Location"
    db-relationship-path="rel_parent.rel_parent"/>

    Now when I run some test code to build a tree in tapestry, the
    following statement gets genereated when I try to fetch children:

    SELECT t0.description, t0.id, t0.parent_id
    FROM dbo.IMV_locations t0, dbo.IMV_locations t1
    WHERE t0.parent_id = t1.id AND (t1.parent_id = ?) [bind: 1]

    This however incorrect, it should read:

    SELECT t0.description, t0.id, t0.parent_id
    FROM dbo.IMV_locations t0, dbo.IMV_locations t1
    WHERE t0.parent_id = t1.id AND (t1.id = ?) [bind: 1]

    Has anyone else had this problem?
    Filip



    This archive was generated by hypermail 2.0.0 : Thu Apr 21 2005 - 18:34:43 EDT