Re: having two sep. foreign keys with same table

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jun 10 2005 - 13:17:05 EDT

  • Next message: Nick Stuart: "Re: Read-only many to many"

    Denna,

    In Cayenne terms you'll have to add 2 DbAttributes to the Deal DbEntity. I
    would call them "primary_contact_id" and "secondary_contact_id" (if needed
    adjust the names to follow your naming convention for DbAttributes).

    Then map 2 corresponding DbRelationships to SystemUser using the following
    joins: (Deal.primary_contact_id/SystemUser.id) and
    (Deal.secondary_contact_id/SystemUser.id)

    Andrus

    P.S. For those who are wondering what this is all about, it is a followup
    on this message (and some offline discussion that we had):
    http://objectstyle.org/cayenne/lists/cayenne-user/2005/06/0019.html

    > Andrus you said,
    >
    > Join on "deal_id" is probably wrong (it seems to be done backwards). If
    > I understand correctly what you are trying to achieve, I'd say Deal table
    > should have two separate foreign keys pointing to SystemUser primary
    > key
    > (e.g. Deal.primaryContactId and Deal.secondaryContactId). Map
    > relationships using those keys. Both forward and reverse relationships
    > should work.
    >
    > Andrei
    >
    > SystemUser has one primary key systemUser_id how do I add two foreign keys
    > for this in Deal in cayenne modeler?
    > Thanks,
    > Denna
    >



    This archive was generated by hypermail 2.0.0 : Fri Jun 10 2005 - 13:17:06 EDT