@Test
public void testFooWithBar() throws Exception {

	Foo foo = repository.query(new Foo()).single();
	foo.barP.set(new Bar());
	foo.barsP.set(Arrays.asList(new Bar(), new Bar()));
	repository.update(foo);
	assertEquals(1, repository.query(new Foo()).count());
	assertEquals(3, repository.query(new Bar()).count());
	foo.barP.set(new Bar());
	foo.barsP.set(Arrays.asList(new Bar(), new Bar()));
	repository.update(foo);
	assertEquals(1, repository.query(new Foo()).count());
	assertEquals(3, repository.query(new Bar()).count());
	foo.barP.set(null);
	foo.barsP.set(Collections.<Bar>emptyList());
	repository.update(foo);
	assertEquals(1, repository.query(new Foo()).count());
	assertEquals(0, repository.query(new Bar()).count());
}