// check if gatherer was stored
tx.begin();
tx.getBroker().clearCache();
assertNotNull(gat.getGatId());
OQLQuery query = odmg.newOQLQuery();
query.create(queryGat);
query.bind(gat.getGatId());
Collection result = (Collection) query.execute();
tx.commit();
assertEquals("Wrong number of objects found", 1, result.size());
Gatherer fetchedGat = (Gatherer) result.iterator().next();
assertNotNull(fetchedGat);
List colC = fetchedGat.getCollectiblesC();
assertEquals("Wrong number of CollectiblesC", 3, colC.size());
// check if gatherer contains list of CollectibleBase
tx.begin();
//**********************************************************
// we replace the collection of main object with a new collection
// reduced by one element
List newCols = new ArrayList();
newCols.add(colC.get(1));
newCols.add(colC.get(2));
// lock object before do changes
tx.lock(fetchedGat, Transaction.WRITE);
fetchedGat.setCollectiblesA(newCols);
// todo: we need to delete removed object explicit?
db.deletePersistent(colC.get(0));
//**********************************************************
tx.commit();
// check if the Collectibles were really deleted from DB
tx.begin();
tx.getBroker().clearCache();
query = odmg.newOQLQuery();
query.create("select colls from " + CollectibleC.class.getName() +
" where name like $1");
query.bind(prefix + "%");
result = (Collection) query.execute();
assertEquals("Wrong number of objects found", 2, result.size());
tx.commit();
// check if the gatherer now contains a CollectibleBase list
// reduced by the deleted
tx.begin();
query = odmg.newOQLQuery();
query.create(queryGat);
query.bind(gat.getGatId());
result = (Collection) query.execute();
assertEquals("Wrong number of objects found", 1, result.size());
fetchedGat = (Gatherer) result.iterator().next();
colC = fetchedGat.getCollectiblesC();
assertEquals("Wrong number of CollectiblesA found in Gatherer", 2, colC.size());
tx.commit();