CollectibleA coll_2 = new CollectibleA(name);
coll_1.setGatherer(gat_1);
coll_2.setGatherer(gat_2);
Transaction tx = odmg.newTransaction();
tx.begin();
db.makePersistent(coll_1);
db.makePersistent(coll_2);
tx.commit();
tx.begin();
((TransactionExt)tx).getBroker().clearCache();
OQLQuery query = odmg.newOQLQuery();
query.create(queryStr);
query.bind(name);
Collection result = (Collection) query.execute();
assertNotNull(result);
assertEquals(2, result.size());
for (Iterator iterator = result.iterator(); iterator.hasNext();)
{
CollectibleA collectible = (CollectibleA) iterator.next();
Gatherer gat = collectible.getGatherer();
assertNotNull(gat);
assertEquals("Gatherer_"+name, gat.getName());
tx.lock(collectible, Transaction.WRITE);
collectible.getGatherer().setName("New_"+name);
}
tx.commit();
tx.begin();
((TransactionExt)tx).getBroker().clearCache();
query = odmg.newOQLQuery();
query.create(queryStr);
query.bind(name);
result = (Collection) query.execute();
assertNotNull(result);
assertEquals(2, result.size());
for (Iterator iterator = result.iterator(); iterator.hasNext();)
{
CollectibleA collectible = (CollectibleA) iterator.next();
Gatherer gat = collectible.getGatherer();
assertNotNull(gat);
assertEquals("New_"+name, gat.getName());
tx.lock(collectible, Transaction.WRITE);
collectible.setGatherer(null);
}
tx.commit();
tx.begin();
((TransactionExt)tx).getBroker().clearCache();
query = odmg.newOQLQuery();
query.create(queryStr);
query.bind(name);
result = (Collection) query.execute();
assertNotNull(result);
assertEquals(2, result.size());
for (Iterator iterator = result.iterator(); iterator.hasNext();)
{
CollectibleA collectible = (CollectibleA) iterator.next();
Gatherer gat = collectible.getGatherer();
assertNull(gat);
}
tx.commit();
}