{
String name = "testImplicitLocking - " + System.currentTimeMillis();
String queryString = "select sites from " + Site.class.getName() + " where name = $1";
/* Create an object */
Site site = new Site();
site.setName(name);
TransactionExt tx = (TransactionExt) odmg.newTransaction();
// disable implicit locking for this tx instance
// this setting was used for the life-time of the tx instance
tx.setImplicitLocking(false);
tx.begin();
database.makePersistent(site);
tx.commit();
/* Retrieve from the object created, and set the year*/
OQLQuery query = odmg.newOQLQuery();
query.create(queryString);
query.bind(name);
tx.begin();
List result = (List) query.execute();
assertEquals(1, result.size());
site = (Site) result.get(0);
assertNotNull(site);
assertNull(site.getYear());
tx.lock(site, Transaction.WRITE);
site.setYear(new Integer(2003));
tx.commit();
/* Flush the cache, and retrieve the object again */
query = odmg.newOQLQuery();
query.create(queryString);
query.bind(name);
tx.begin();
tx.getBroker().clearCache();
result = (List) query.execute();
assertEquals(1, result.size());
site = (Site) result.get(0);
assertNotNull(site);
assertNotNull("year should not be null", site.getYear());
tx.commit();
}