Missing part of FK on a toOne toOne

From: Mike Block (mbloc..ac.com)
Date: Fri Oct 10 2003 - 13:31:43 EDT

  • Next message: Andrus Adamchik: "Re: Missing part of FK on a toOne toOne"

    I am using cayenne 1.0 release.

    I have two entities:
            Contact and Dealer
    The basic idea here is that a Dealer HASA Contact.

    There is a bi-directional toOne relationship between the two entities
    (Contact.toDealer and Dealer.toContact). The toDepPK is not checked in
    either direction (modeler does not allow it to be).

    The database tables are:

    CREATE TABLE public.contact (
            id bigint NOT NULL,
            name varchar(40) NOT NULL,
            * * *
            PRIMARY KEY (id)
    );

    CREATE TABLE public.dealer (
            id bigint NOT NULL,
            contact_id bigint NOT NULL,
            name varchar(100) NULL,
            PRIMARY KEY (id)
    );
    ALTER TABLE public.dealer ADD FOREIGN KEY (contact_id) REFERENCES
    public.contact (id);

    contact to dealer:
            source: id
            target: contact_id

    dealer to contact:
            source: contact_id
            target: id

    My code simply instantiates a Contact via createAndRegisterNewObject;
    uses the setXXX() to fill in its required fields.
    Dealer is instantiated in a similar fashion.
    contact.toDealer(dealer);
    commitChanges();

    The result is:
            org.objectstyle.cayenne.CayenneRuntimeException: [v.1.0 September 20
    2003] Some parts of FK are missing in snapshot.
    The contact and dealer objects look like this (right before the commit):
    Contact: {[ state => PA
             phoneNumber => 555-1212
             address1 => 1010 E. Westave St.
             toDealer => {<oid: blickmanDB.contact.Dealer (temp): ; state:
    new>}

             name => Bat Manuel
             zipcode => 19999
             city => Philly
    ]<oid: blickmanDB.contact.Contact (temp): ; state: new>}

    Dealer : {[ toContact => {<oid: blickmanDB.contact.Contact (temp):
    ; state: new>}

             name => Biggie Small
    ]<oid: blickmanDB.contact.Dealer (temp): ; state: new>}

    Any help would be much appreciated.
    Thanks.

    I did see the posts on this issue which pointed to making sure the
    toDepPK is set appropriately.



    This archive was generated by hypermail 2.0.0 : Fri Oct 10 2003 - 13:31:43 EDT