Hi Noel,
Attached is a little sample app that I wrote for your case. It works
traversing from child or from parent. The only caveat is that the modeler
does not allow you to "flatten" the relationship, so I had to map a join
table as an ObjEntity. Aside from a small inconvenience this creates,
everything works as expected.
I guess we need to see if we should allow flattened relationships for this
case, but this shouldn't be a show stopper for you.
Andrus
> Hello,
>
> I've been trying to use cayenne for a few days now and I've come across
> a problem I just can't seem to get around / figure out.
>
> I have 2 tables. One called Person, the other called Parent_Child. The
> structure of each is:
>
> **Person**
> ID -> Integer (Primary Key)
> Name -> varchar
>
> **Parent_Child**
> parent_id -> Integer
> child_id -> Integer
>
> As you may have guessed, each row of the parent_child table simply
> stores the Person_IDs of a parent and child.
>
> So, using the modeler, how do you set this up? I can't seem to get it
> right to save my life. I want to have a method on my resulting Person
> Object called, "getChildren" which returns all of the children for the
> given person AND I want a method called "getParents" which would return
> a list of the parents for the given person. The best I've been able to
> get to happen is either the list is null or I get the root person back
> (i.e. when i ask for my children, I get myself, etc).
>
> Can anyone help me? The tutorials (in their current state), don't have
> an example of this.
>
> Noel Murphy
This archive was generated by hypermail 2.0.0 : Mon Oct 20 2003 - 12:49:20 EDT