Re: relationship between inherited entities

From: sabiha (sdilovi..ahoo.com)
Date: Fri Apr 16 2004 - 15:41:31 EDT

  • Next message: Eddy Young: "Interface, abstract classes and Cayenne"

    Hi Andrus,

     

    Thanks for your help. I had success with this relationship. I did exactly what you suggested me to do and it works.

     

    I added an extra attribute “is_manager” (relevant only for “developer” that it can be aware of corresponding “manager”) to “Employee” DbEntity and its value is “employee_id” of corresponding “manager”.

    And I created 2 DbRelationhips for “Employee” DbEntity: 1st is “employees”, to-many relationship, with *target* “Employee”, and joined with *source* “employee_id”, *target* “is_manager”.

    2nd is “toManager”, with *target* “Employee”, and joined with *source* “is_manager”, *target* “employee_id”.

    And then I created ObjRelationship in “Manager” that maps to “employees” DbRelationship.

     

    Thanks

    Sabiha

     

    Andrus Adamchik <andru..bjectstyle.org> wrote:
    Hi Sabiha,

    > if I want to have relationship (to-many) between “Manager” and
    > “Developer”, how to implement it?

    Actually I haven't tested such case yet, but I don't see why it
    wouldn't work... To map such relationship, create a corresponding
    self-referencing pair of DbRelationships in Employee *DbEntity*, for
    instance called "employees" and "toManager". Then create a new
    ObjRelationship in Manager ObjEntity (but not in Employee ObjEntity)
    that maps to "employees" DbRelationship.

    Let us know how this worked.

    > Did I miss something here or did something wrong?

    You also need to do some "magic" with your data objects per chapter
    8.6.1 buried deep in the user guide:
    http://objectstyle.org/cayenne/userguide/dataobjects/dataobjects-
    inheritance.html . This step is probably just a temporary thing.
    Hopefully in the next releases we will move this information it to the
    mapping.

    Cheers
    Andrus

                    
    ---------------------------------
    Do you Yahoo!?
    Yahoo! Tax Center - File online by April 15th



    This archive was generated by hypermail 2.0.0 : Fri Apr 16 2004 - 15:41:35 EDT