// 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);
// check if gatherer contains list of CollectibleBase
List colC = fetchedGat.getCollectiblesC();
assertEquals("Wrong number of CollectiblesC", 3, colC.size());
tx.begin();
//*************************************
tx.lock(fetchedGat, Transaction.WRITE);
// Now add a new collection object
CollectibleC newC = new CollectibleC(prefix, null, "### new added ###");
fetchedGat.getCollectiblesC().add(newC);
newC.setGathererId(fetchedGat.getGatId());
tx.lock(newC, Transaction.WRITE);
//*************************************
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", 4, result.size());
tx.commit();
// check if the gatherer now contains a CollectibleBase list
// increased by the added
tx.begin();
tx.getBroker().clearCache();
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", 4, colC.size());
tx.commit();