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 - 11:30:55 EST