childModifiedSimple.setPaintingTitle("C_PT");
Painting childModifiedToOne = (Painting) objects.get(1);
childModifiedToOne.setToArtist(childModifiedSimple.getToArtist());
Artist childModifiedToMany = ((Painting) objects.get(2)).getToArtist();
// ensure painting array is fully resolved...
childModifiedToMany.getPaintingArray().size();
childModifiedToMany.addToPaintingArray((Painting) objects.get(3));
blockQueries();
Painting parentModifiedSimple = null;
Artist parentModifiedToMany = null;
try {
childContext.commitChangesToParent();
assertEquals(PersistenceState.COMMITTED, childModifiedSimple
.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, childModifiedToOne
.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, childModifiedToMany
.getPersistenceState());
parentModifiedSimple = (Painting) context.getGraphManager().getNode(
childModifiedSimple.getObjectId());
Painting parentModifiedToOne = (Painting) context.getGraphManager().getNode(
childModifiedToOne.getObjectId());
parentModifiedToMany = (Artist) context.getGraphManager().getNode(
childModifiedToMany.getObjectId());
assertNotNull(parentModifiedSimple);
assertEquals(PersistenceState.MODIFIED, parentModifiedSimple
.getPersistenceState());
assertEquals("C_PT", parentModifiedSimple.getPaintingTitle());
assertNotNull(context.getObjectStore().getChangesByObjectId().get(
parentModifiedSimple.getObjectId()));
assertNotNull(parentModifiedToOne);
assertEquals(PersistenceState.MODIFIED, parentModifiedToOne
.getPersistenceState());
assertNotNull(parentModifiedToOne.getToArtist());
assertEquals(33001, Cayenne.intPKForObject(parentModifiedToOne
.getToArtist()));
assertNotNull(context.getObjectStore().getChangesByObjectId().get(
parentModifiedToOne.getObjectId()));
// indirectly modified....
assertNotNull(parentModifiedToMany);
assertEquals(PersistenceState.MODIFIED, parentModifiedToMany
.getPersistenceState());
}
finally {
unblockQueries();
}
// here query is expected, as the parent was hollow and its to-many relationship
// is unresolved
List paintings = parentModifiedToMany.getPaintingArray();
assertEquals(2, paintings.size());
}