Re: Hierarchical relationship problems

From: Cris Daniluk (cris.danilu..mail.com)
Date: Fri Apr 22 2005 - 09:49:42 EDT

  • Next message: Gentry, Michael \(Contractor\): "RE: Doing logical AND in Cayenne"

    Actually, it looks backward to me too (though no morning coffee yet,
    so maybe you're right)... you know that if the relationships are
    backward and you use Cayenne to create the tree, then of course
    reading it will be backward too, right? Sounds like you were using
    Cayenne for both ends...

    And of course, getChildren should always be a toMany.

    On 4/22/05, Filip Balas <fbala..mail.com> wrote:
    > 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 - 09:49:44 EDT