ds.put(e);
Flight f = pm.getObjectById(Flight.class, e.getKey());
// make a copy right away, otherwise our change will get reverted
// when the txn rolls back
Flight fCopy = pm.detachCopy(f);
ExceptionThrowingDatastoreDelegate dd =
new ExceptionThrowingDatastoreDelegate(getDelegateForThread(), policy);
setDelegateForThread(dd);
try {
// update attached object
fCopy.setYou(12);
try {
pm.makePersistent(fCopy);
pm.close();
fail("expected exception");
} catch (JDODataStoreException ex) {
// good
assertTrue(ex.getCause() instanceof ConcurrentModificationException);
}
pm = pmf.getPersistenceManager();
pm.makePersistent(fCopy);
pm.close();
pm = pmf.getPersistenceManager();
f = pm.getObjectById(Flight.class, e.getKey());
assertEquals(f, "harold", "bos", "mia", 12, 24, 88);
pm.close();
} finally {
setDelegateForThread(dd.getInner());
}
}