tx.commit();
// query and check the result
tx.begin();
tx.getBroker().clearCache();
OQLQuery query = odmg.newOQLQuery();
query.create(queryStr);
assertNotNull(gat.getGatId());
query.bind(gat.getGatId());
query.bind(gat2.getGatId());
Collection result = (Collection) query.execute();
tx.commit();
assertEquals("Wrong number of objects found", 2, result.size());
Iterator it = result.iterator();
Gatherer fetchedGat = (Gatherer) it.next();
Gatherer fetchedGat2 = (Gatherer) it.next();
assertNotNull(fetchedGat);
assertNotNull(fetchedGat2);
assertEquals("Wrong gatherer returned: fetchedGat should be first Gatherer",
gat1Name, fetchedGat.getName());
assertEquals("Wrong gatherer returned: fetchedGat2 should be second Gatherer",
gat2Name, fetchedGat2.getName());
assertNotNull(fetchedGat.collectiblesC);
assertNotNull(fetchedGat2.collectiblesC);
assertEquals(1, fetchedGat.getCollectiblesC().size());
assertEquals(1, fetchedGat2.getCollectiblesC().size());
collC_1 = (CollectibleC) fetchedGat.getCollectiblesC().get(0);
collC_2 = (CollectibleC) fetchedGat2.getCollectiblesC().get(0);
assertEquals(prefix + "NO_1", collC_1.getName());
assertEquals(prefix + "NO_2", collC_2.getName());
//*****************************************************
List list1 = fetchedGat.getCollectiblesC();
List list2 = fetchedGat2.getCollectiblesC();
// now exchange the lists
tx.begin();
tx.lock(fetchedGat, Transaction.WRITE);
tx.lock(fetchedGat2, Transaction.WRITE);
fetchedGat.setCollectiblesC(list2);
fetchedGat2.setCollectiblesC(list1);
// System.out.println("#####===> start commit");
tx.commit();
//*****************************************************
// System.out.println("#####===> end commit");
// now we do same procedure to query and check
tx.begin();
tx.getBroker().clearCache();
query = odmg.newOQLQuery();
query.create(queryStr);
assertNotNull(gat.getGatId());
query.bind(gat.getGatId());
query.bind(gat2.getGatId());
result = (Collection) query.execute();
tx.commit();
assertEquals("Wrong number of objects found", 2, result.size());
it = result.iterator();
fetchedGat = (Gatherer) it.next();
fetchedGat2 = (Gatherer) it.next();