I am still dubious that this is Cayenne problem as we have test cases that
cover this situation. So I recommend doublechecking that you don't have
your old incorrect DataMap sitting somewhere in the classpath, and also
check if it works with Cayenne 1.1.1 (unless your code depends heavily on
1.2 API making this impossible).
If it still doesn't work, please submit a bug report containing DataMap
XML file and a code snippet that trigers this fetch.
Andrus
> I'm on the bleeding edge (could be why I'm having the
> problem) cayenne 1.2M3.
>
> Filip
>
>
> On 4/25/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
>> You shouldn't have to do anything special. Cayenne (including the
>> Modeler) works fine with simple parent-child hierarchies. For
>> "children" I expect the generated query to look even simpler:
>>
>> SELECT t0.description, t0.id, t0.parent_id
>> FROM dbo.IMV_locations t0, dbo.IMV_locations t1
>> WHERE t0.parent_id = ? [bind: 1]
>>
>> So ... What version of Cayenne do you have? There was a bug long time
>> ago that messed it up, but I am fairly sure it is fixed in 1.1 final
>> and 1.1.1 releases.
>>
>> Andrus
>>
>>
>> > Hi Andrus,
>> >
>> > Yes that makes perfect sense. I didn't catch that error, I just
>> assumed the modeler would generate the right xml when
>> > I selected the proper source and target.
>> >
>> > However, even when I corrected the xml manually to your
>> > suggestion, I still have the following statement generated
>> > by cayenne:
>> >
>> > 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]
>> >
>> > I need it to 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]
>> >
>> > In another spot in my code I have a hierarchy set up but
>> > it is a many to many (map, not tree) and cayenne seems
>> > to deal with that beautifully. To achieve this I have an
>> intermediate table that maps locations to one another. Will I have
>> to add
>> > this extra table with a one-To-one constraint to ensure a tree
>> structure and not a map?
>> >
>> > Thanks to all who have answered.
>> > Your help is greatly appreciated.
>> > Filip
>> >
>> >
>> >
>> > On 4/24/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
>> >> Hi Filip,
>> >>
>> >> > <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"/>
>> >>
>> >> The way relationships above are mapped you'll be getting
>> GRANDchildren and GRANDparents. Is this really what you want? The
>> query you quote seems correct (for grandchildren). What I mean is
>> that
>> >>
>> >>
>> >> > 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]
>> >>
>> >> is a short form for
>> >>
>> >> SELECT t0.description, t0.id, t0.parent_id
>> >> FROM dbo.IMV_locations t0, dbo.IMV_locations t1, dbo.IMV_locations
>> t2 WHERE t0.parent_id = t1.id AND t1.parent_id = t2.id AND t2.id =
>> ? [bind: 1]
>> >>
>> >> (see an extra join)... If you need direct children, then you need
>> to remove the last component in the obj-relationship path. The
>> resulting mapping should look like this:
>> >>
>> >>
>> >> <obj-relationship name="children" source="Location"
>> target="Location" deleteRule="Cascade"
>> >> db-relationship-path="rel_children"/>
>> >>
>> >> <obj-relationship name="parent" source="Location" target="Location"
>> db-relationship-path="rel_parent"/>
>> >>
>> >> I hope I understood your requirements correctly...
>> >>
>> >> Andrus
>> >>
>> >>
>> >
>> >
>> > --
>> > Cell : 403.461.7895
>> > Work: 403.770.1534
>> > MSN: fbala..otmail.com
>>
>>
>
>
> --
> Cell : 403.461.7895
> Work: 403.770.1534
> MSN: fbala..otmail.com
This archive was generated by hypermail 2.0.0 : Mon Apr 25 2005 - 16:58:17 EDT