ToManyRoot2 src2 = context.newObject(ToManyRoot2.class);
ToManyFkRoot src = context.newObject(ToManyFkRoot.class);
// this should go away when such mapping becomes fully supported
src.setDepId(new Integer(1));
ToManyFkDep target = context.newObject(ToManyFkDep.class);
// this should go away when such mapping becomes fully supported
target.setDepId(new Integer(1));
target.setRoot2(src2);
src.addToDeps(target);
context.commitChanges();
context.invalidateObjects(src, target, src2);
ToManyFkRoot src1 = (ToManyFkRoot) Cayenne
.objectForPK(context, src.getObjectId());
assertNotNull(src1.getDeps());
assertEquals(1, src1.getDeps().size());
// resolve HOLLOW
assertSame(src1, ((ToManyFkDep) src1.getDeps().get(0)).getRoot());
context.invalidateObjects(src1, src1.getDeps().get(0));
ToManyFkDep target2 = (ToManyFkDep) Cayenne.objectForPK(context, target
.getObjectId());
assertNotNull(target2.getRoot());
// resolve HOLLOW
assertSame(target2, target2.getRoot().getDeps().get(0));
}