Map<Object, ClientMtMapToManyTarget> targets = o1.getTargets();
assertNotNull(targets);
assertEquals(3, targets.size());
ClientMtMapToManyTarget newTarget = o1.getObjectContext().newObject(
ClientMtMapToManyTarget.class);
o1.addToTargets(newTarget);
assertEquals(4, targets.size());
assertSame(o1, newTarget.getMapToMany());
o1.getObjectContext().commitChanges();
o1.getObjectContext().performGenericQuery(new RefreshQuery());
assertEquals(4, o1.getTargets().size());
int newId = Cayenne.intPKForObject(newTarget);
assertSame(newTarget, o1.getTargets().get(new Integer(newId)));
assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
assertEquals(PersistenceState.COMMITTED, newTarget.getPersistenceState());
}