Re: Relationship frustration

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Dec 17 2003 - 15:05:58 EST

  • Next message: Jim Menard: "Flattened relationships are read-only?"

    On Dec 17, 2003, at 2:47 PM, Jim Menard wrote:

    > Schema Generation Error: Failed statement: ALTER TABLE public.address
    > ADD FOREIGN KEY (id) REFERENCES public.bill_account (bill_address_id)
    > - ERROR: UNIQUE constraint matching given keys for refenced table
    > "bill_account" not found.

    The reason for that is that a relationship to an FK is "to many" in DB
    terms. So Cayenne is being confused when it is specified as "to one"
    and attempts to generate an FK constraint. E.g.:
    http://objectstyle.org/cayenne/lists/cayenne-user/2003/11/0066.html

    One possible workaround that you can use right away is to define it as
    to-many in the model, especially since you don't care about this
    relationship (so you don't have to define it in your object).

    As a short term solution in Cayenne we should detect these
    relationships and do not try to generate an FK. As a long term solution
    we may allow users to specify whether this is a true FK, and if so,
    generate a unique constraint in addition to FK constraint. I will open
    a bug for that, but it should not affect your immediate development.

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Dec 17 2003 - 15:06:04 EST