public void testRemove() throws Exception {
Painting p1 = context.newObject(Painting.class);
p1.setPaintingTitle("xa");
Gallery g1 = context.newObject(Gallery.class);
g1.setGalleryName("yT");
p1.setToGallery(g1);
// do save
context.commitChanges();
ObjectContext context2 = runtime.newContext();
// test database data
Painting p2 = (Painting) Cayenne.objectForQuery(context2, new SelectQuery(
Painting.class));
Gallery g2 = p2.getToGallery();
p2.setToGallery(null);
// test before save
assertEquals(0, g2.getPaintingArray().size());
assertNull(p2.getToGallery());
// do save II
context2.commitChanges();