Re: Hierarchical relationship problems

From: Filip Balas (fbala..mail.com)
Date: Fri Apr 22 2005 - 08:30:15 EDT

  • Next message: Dhruti Ramani: "Doing logical AND in Cayenne"

    Well would you care to share this strange thinking
    with the group? Considering that the 'parent' relationship
    works as expected, it seems unlikely that my
    relation is upside-down. If I were to invert the relation
    (which I did try before posting) then getChildren returns
    one obejct (and not a list as it should) which is it's
    parent. 'getParent' then becomes the problem.

    Filip

    On 4/22/05, Jürgen Saar <jsaa..eb.de> wrote:
    > I've had the same problem with self referencing,
    > on my first try.
    >
    > Your relation is upside-down
    >
    > It needs a little strange thinking to get it right.
    >
    > cayenne-use..bjectstyle.org schrieb am 22.04.05 00:35:02:
    > >
    > > 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
    >
    > __________________________________________________________
    > Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
    > weltweit telefonieren! http://freephone.web.de/?mc=021201
    >
    >

    -- 
    Cell  : 403.461.7895
    Work: 403.770.1534
    MSN:  fbala..otmail.com
    



    This archive was generated by hypermail 2.0.0 : Fri Apr 22 2005 - 08:30:17 EDT