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

From: Dave Paules (dn..uantumleap.us)
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
    tuple.

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

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

    Employee
    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
    www.leapworks.com

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: Friday, January 03, 2003 11:31 AM
    To: Dave Paules
    Cc: 'cayenne-use..bjectstyle.org'
    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.

    Andrus

     

    Dave Paules writes:
    > I am trying to create a new Employee and create a new RetirementAccount
    for
    > the new employee.
    > It seems I can create and save these objects independently to the
    database,
    > but if I try to "connect" the two in the 1:1 relationship that I modeled,
    I
    > get the following exception at the ctxt.commitChanges method call:
    >
    > org.objectstyle.cayenne.CayenneRuntimeException: Some parts of PK are
    > missing in snapshot.
    > at
    >
    org.objectstyle.cayenne.map.DbRelationship.srcFkSnapshotWithTargetSnapshot(D
    > bRelationship.java:251)
    > at
    >
    org.objectstyle.cayenne.access.SnapshotManager.takeObjectSnapshot(SnapshotMa
    > nager.java:243)
    > at
    >
    org.objectstyle.cayenne.access.DataContext.takeObjectSnapshot(DataContext.ja
    > va:286)
    > at
    >
    org.objectstyle.cayenne.CayenneDataObject.getCurrentSnapshot(CayenneDataObje
    > ct.java:378)
    > at
    > org.objectstyle.cayenne.QueryHelper.updateQuery(QueryHelper.java:105)
    > at
    >
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:61
    > 5)
    > at Tester.addIntern(Tester.java:72)
    > at Tester.run(Tester.java:42)
    > at Tester.main(Tester.java:27)
    >
    >
    > <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