{
restore = true;
conf.setUseImplicitLocking(false);
}
Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();
db.open(databaseName, Database.OPEN_READ_WRITE);
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);
Transaction tx = odmg.newTransaction();
tx.begin();
tx.lock(site, Transaction.WRITE);
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.UPGRADE);
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();
((HasBroker) 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();
db.close();
}
finally
{
// reset configuration
if(restore)