RE: error on 1:1 relationship - Some parts of PK are missing in s naps hot

From: Dave Paules (
Date: Fri Jan 03 2003 - 12:42:09 EST

  • Next message: Andrus Adamchik: "Re: error on 1:1 relationship - Some parts of PK are missing in s naps hot"

    Hello Andrus,

    Well, I am not certain what "PK-> dep. PK" means. When I used EOModeler the
    meaning of "Dependent Primary Key" could mean different things depending on
    what you were talking about. Usually it meant that if I added a new Employee
    object and a new RetirementAccount object, the primary key value for the
    Employee tuple would ALSO be the primary key value for the RetirementAccount

    My database setup is different. RetirementAccounts have a primary key column
    that is completely arbitrary and not linked to the Employee table at all.

    accountId | employeeId | dateOpened
        1 1 12-01-02
        2 6 10-26-01
        5 3 04-13-00

    employeeId | firstName | lastName
        1 David Paules
        2 Julie Johnson
        3 Bob Smith
        4 James Carlson
        5 Kathy Bates
        6 Iris Kunczyk

    The small data set above is how the database is designed. Hopefully this
    will allow you to tell me two things:
    1. What does "To Dep PK" mean in Cayenne Modeler? With regard to your
    suggestion of setting that checkbox on the db relationship from Employee to
    RetirementAccount, the modeler will not allow me to check it. When I do
    check it by setting the xml text to true, the run-time tells me that "the
    toDependentPK value is incorrectly set to true, unsetting it".

    2. I have a reverse relationship from retirement account back to employee.
    Thus I have the "update reverse" checkbox on the db relationship checked.
    What does this checkbox mean?

    Thanks in advance for your time and help,
    Dave Paules
    Quantum Leap Innovations

    -----Original Message-----
    From: Andrus Adamchik []
    Sent: Friday, January 03, 2003 11:31 AM
    To: Dave Paules
    Cc: ''
    Subject: Re: error on 1:1 relationship - Some parts of PK are missing in
    snaps hot

    Hi Dave,

    the code looks absolutely correct.

    To answer your question, could you provide some information about how the
    one-to-one is mapped. Is it PK-> dep. PK? If so, is the corresponding
    checkbox checked on DbRelationship from Employee to RetirementAccount?

    Details of your db schema for these 2 tables will help too.



    Dave Paules writes:
    > I am trying to create a new Employee and create a new RetirementAccount
    > the new employee.
    > It seems I can create and save these objects independently to the
    > but if I try to "connect" the two in the 1:1 relationship that I modeled,
    > get the following exception at the ctxt.commitChanges method call:
    > org.objectstyle.cayenne.CayenneRuntimeException: Some parts of PK are
    > missing in snapshot.
    > at
    > at
    > at
    > va:286)
    > at
    > at
    > org.objectstyle.cayenne.QueryHelper.updateQuery(
    > at
    > 5)
    > at Tester.addIntern(
    > at
    > at Tester.main(
    > <code>
    > Employee intern = (Employee)ctxt.createAndRegisterNewObject("Employee");
    > intern.setFirstName("Julie");
    > intern.setLastName("Johnson");
    > //now add retirement account
    > RetirementAccount ira =
    > (RetirementAccount)ctxt.createAndRegisterNewObject("RetirementAccount");
    > ira.setDateOpened(new java.sql.Date(System.currentTimeMillis()));
    > ira.setAccountNumber(new Integer(177567233));
    > //now connect the two
    > intern.setRetirementAccount(ira);
    > ctxt.commitChanges(Level.WARN);
    > </code>
    > What am I doing wrong? Have I modeled something incorrectly?
    > DaveP

    This archive was generated by hypermail 2.0.0 : Fri Jan 03 2003 - 12:44:37 EST