/**
* Tests that modification to read only objects are not persist in the
* database.
*/
public void runTest() throws PersistenceException {
OQLQuery oql;
Sample object;
Enumeration enumeration;
// load an object using readOnly mode
_db.begin();
oql = _db.getOQLQuery("SELECT object FROM "
+ Sample.class.getName() + " object WHERE id = $1");
oql.bind(Sample.DEFAULT_ID);
enumeration = oql.execute(Database.READONLY);
object = (Sample) enumeration.nextElement();
LOG.debug("Retrieved object: " + object);
object.setValue1(NEW_VALUE);
LOG.debug("Modified object: " + object);
_db.commit();
// read the object from another transaction to see
// if changes is not persisted.
_db.begin();
oql.bind(Sample.DEFAULT_ID);
enumeration = oql.execute(Database.READONLY);
object = (Sample) enumeration.nextElement();
LOG.debug("Retrieved object: " + object);
if (object.getValue1().equals(NEW_VALUE)) {
LOG.error("Error: modified object was stored");
fail("Modified object was stored");