assertEquals(4, o1.getTargets().size());
}
public void testRemoveToMany() throws Exception {
CollectionToMany o1 = Cayenne.objectForPK(context, CollectionToMany.class, 1);
Collection<?> targets = o1.getTargets();
assertEquals(3, targets.size());
CollectionToManyTarget target = Cayenne.objectForPK(
o1.getObjectContext(),
CollectionToManyTarget.class,
2);
o1.removeFromTargets(target);
assertEquals(2, targets.size());
assertFalse(o1.getTargets().contains(target));
assertNull(target.getCollectionToMany());
o1.getObjectContext().commitChanges();
o1.getObjectContext().performGenericQuery(new RefreshQuery());
assertEquals(2, o1.getTargets().size());
assertFalse(o1.getTargets().contains(target));
}