public void testSimpleSerializeWithTxns()
throws IOException, ClassNotFoundException, EntityNotFoundException {
pm.setDetachAllOnCommit(true);
beginTxn();
DetachableJDO pojo = new DetachableJDO();
pojo.setVal("yar");
Date now = new Date();
pojo.setDate(now);
pm.makePersistent(pojo);
commitTxn();
assertEquals(ObjectState.DETACHED_CLEAN, JDOHelper.getObjectState(pojo));
assertEquals(Date.class, pojo.getDate().getClass());
pm.close();
assertEquals(ObjectState.DETACHED_CLEAN, JDOHelper.getObjectState(pojo));
pm = pmf.getPersistenceManager();
assertEquals(ObjectState.DETACHED_CLEAN, JDOHelper.getObjectState(pojo));
pojo = toBytesAndBack(pojo);
assertEquals("yar", pojo.getVal());
assertEquals(now, pojo.getDate());
assertEquals(ObjectState.DETACHED_CLEAN, JDOHelper.getObjectState(pojo));
beginTxn();
assertEquals(ObjectState.DETACHED_CLEAN, JDOHelper.getObjectState(pojo));
pojo.setVal("not yar");
Date newDate = new Date(pojo.getDate().getTime() + 1);
pojo.getDate().setTime(newDate.getTime());
assertEquals(ObjectState.DETACHED_DIRTY, JDOHelper.getObjectState(pojo));
pm.makePersistent(pojo);
commitTxn();
Entity e = ds.get(KeyFactory.createKey(DetachableJDO.class.getSimpleName(), pojo.getId()));
assertEquals("not yar", e.getProperty("val"));
assertEquals(newDate, e.getProperty("date"));
}