ObjectContext childContext = context.createChildContext();
Painting childMaster = childContext.newObject(Painting.class);
childMaster.setPaintingTitle("Master");
PaintingInfo childDetail1 = childContext.newObject(PaintingInfo.class);
childDetail1.setTextReview("Detail1");
childDetail1.setPainting(childMaster);
try {
childContext.commitChangesToParent();
assertEquals(PersistenceState.COMMITTED, childMaster.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, childDetail1.getPersistenceState());
Painting parentMaster = (Painting) context.getGraphManager().getNode(
childMaster.getObjectId());
assertNotNull(parentMaster);
assertEquals(PersistenceState.NEW, parentMaster.getPersistenceState());
PaintingInfo parentDetail1 = (PaintingInfo) context
.getGraphManager()
.getNode(childDetail1.getObjectId());
assertNotNull(parentDetail1);
assertEquals(PersistenceState.NEW, parentDetail1.getPersistenceState());
assertSame(parentMaster, parentDetail1.getPainting());
assertSame(parentDetail1, parentMaster.getToPaintingInfo());
}
finally {
unblockQueries();
}