I am going to try remodeling the entire application by hand
from scratch (grrrr...). I used the reengineer feature, which
I think may be what is causing the problem.
Filip
On 4/28/05, Filip Balas <fbala..mail.com> wrote:
> I tried manually inserting the code to setParent, addTo/RemoveFrom
> children (I used the code from the isolated table that worked as a
> template) but it does not work. Cayenne will not set the parent even
> though it does not throw any exceptions... I am puzzled.
>
> Filip
>
>
> On 4/28/05, Filip Balas <fbala..mail.com> wrote:
> > Interesting... I have reproduced your results on an isolated
> > table. However, my real scenario has relationships to other
> > tables and other dataMaps so other than that it is identical.
> > Except for the fact that it does not generate the proper
> > add/set/remove methods. Have you seen this before?
> >
> > Filip
> >
> > On 4/27/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
> > > Flattened relationships are those that span more than one
> > > DbRelationship. You don't have them in the mapping below, but you used
> > > to have them in the mapping that you posted here before...
> > >
> > > Anyway, I took your mapping and successfully generated classes with all
> > > normal "set/add/remove" methods... So back to my initial advise - make
> > > sure that you are generating classes from the DataMap below and not
> > > some old copy.
> > >
> > > Andrus
> > >
> > > On Apr 27, 2005, at 6:44 PM, Filip Balas wrote:
> > > > Hi Andrus,
> > > >
> > > > Here is what I'm working with:
> > > >
> > > > <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"/>
> > > >
> > > > <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" toDependentPK="true" toMany="false">
> > > > <db-attribute-pair source="parent_id" target="id"/>
> > > > </db-relationship>
> > > >
> > > > <obj-entity name="Location"
> > > > className="com.imvprojects.phoneList.data.Location"
> > > > dbEntityName="IMV_locations">
> > > > <obj-attribute name="_description" type="java.lang.String"
> > > > db-attribute-path="description"/>
> > > > </obj-entity>
> > > >
> > > > <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" isGenerated="true" length="10"/>
> > > > <db-attribute name="parent_id" type="INTEGER" length="10"/>
> > > > </db-entity>
> > > >
> > > > I'm not sure what you mean by flattened relationships?
> > > > Do you mean the fact that I am using only one table to
> > > > represent the relationship? Should I be breaking this out?
> > > > I have another relationship where I have a 1:n relationship
> > > > which I have represented in a seperate table (for reasons
> > > > which are not relevent to the discussion) and this class
> > > > has all of the appropriate accessors.
> > > >
> > > > Thanks,
> > > > Filip
> > > >
> > > >
> > > >
> > > > On 4/27/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
> > > >> Doublecheck that you cleared those bogus flattened relationships.
> > > >>
> > > >> Read-only relationships are usually generated for all flattened
> > > >> relationships that Cayenne treats are non-updateable (i.e. all except
> > > >> m:n
> > > >> with a single join table). I suspect this is the cause of the problem.
> > > >>
> > > >> Andrus
> > > >>
> > > >>
> > > >>> I didn't notice this before but it appears cayenne
> > > >>> did not generate modifiers for the hierarchical class?
> > > >>>
> > > >>> What I mean is this:
> > > >>>
> > > >>> I HAVE:
> > > >>> Location getParent()
> > > >>> List getChildren();
> > > >>>
> > > >>> I am MISSING:
> > > >>> setParent(Location)
> > > >>> addToChildren(Location)
> > > >>> removeFromChildren(Location)
> > > >>>
> > > >>> I have checked to make sure I didn't inadvertantly
> > > >>> make the entity read-only. Any suggestions?
> > > >>>
> > > >>> Thanks,
> > > >>> Filip
> > > >>>
> > > >>>
> > > >>> On 4/25/05, Filip Balas <fbala..mail.com> wrote:
> > > >>>> Just a quick update so that no one wastes anymore
> > > >>>> time on this other than me. It appears that with the
> > > >>>> clean test, cayenne handles everything just fine.
> > > >>>>
> > > >>>> There must be something else in how I've used the
> > > >>>> modeler or set up the relationships in the database
> > > >>>> that is causing this to happen.
> > > >>>>
> > > >>>> Thanks for your input Andrus, just know that there is
> > > >>>> a test case for this was motivation enough to prove
> > > >>>> myself wrong.
> > > >>>>
> > > >>>> Cheers,
> > > >>>> Filip
> > > >>>>
> > > >>>>
> > > >>>> On 4/25/05, Filip Balas <fbala..mail.com> wrote:
> > > >>>>> Hmmm, okay I don't like to blame someone else's code
> > > >>>>> unless I'm 100% sure. Later today I will set up a purely
> > > >>>>> clean test (seperate table, seperate map, sperate test class). If
> > > >>>> this doesn't work I'll submit a bug...
> > > >>>>>
> > > >>>>> Thanks again,
> > > >>>>> Filip
> > > >>>>>
> > > >>>>> On 4/25/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
> > > >>>>>> 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
> > > >>>>>>
> > > >>>>>>
> > > >>>>>
> > > >>>>> --
> > > >>>>> Cell : 403.461.7895
> > > >>>>> Work: 403.770.1534
> > > >>>>> MSN: fbala..otmail.com
> > > >>>>>
> > > >>>>
> > > >>>> --
> > > >>>> Cell : 403.461.7895
> > > >>>> Work: 403.770.1534
> > > >>>> MSN: fbala..otmail.com
> > > >>>>
> > > >>>
> > > >>>
> > > >>> --
> > > >>> Cell : 403.461.7895
> > > >>> Work: 403.770.1534
> > > >>> MSN: fbala..otmail.com
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > Cell : 403.461.7895
> > > > Work: 403.770.1534
> > > > MSN: fbala..otmail.com
> > > >
> > >
> > >
> >
> > --
> > Cell : 403.461.7895
> > Work: 403.770.1534
> > MSN: fbala..otmail.com
> >
>
> --
> 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 : Thu Apr 28 2005 - 13:00:56 EDT