}
public void testSimpleSerializeWithTxns()
throws IOException, ClassNotFoundException, EntityNotFoundException {
beginTxn();
DetachableJPA pojo = new DetachableJPA();
pojo.setVal("yar");
Date now = new Date();
pojo.setDate(now);
em.persist(pojo);
commitTxn();
assertEquals(ObjectState.HOLLOW_PERSISTENT_NONTRANSACTIONAL, JDOHelper.getObjectState(pojo));
assertTrue(Date.class.isAssignableFrom(pojo.getDate().getClass()));
em.close(); // Detaches objects in L1 cache
assertEquals(ObjectState.DETACHED_CLEAN, JDOHelper.getObjectState(pojo));
em = emf.createEntityManager();
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 differentNow = new Date(now.getTime() + 1);
pojo.setDate(differentNow);
assertEquals(ObjectState.DETACHED_DIRTY, JDOHelper.getObjectState(pojo));
pojo = em.merge(pojo);
assertEquals(ObjectState.PERSISTENT_DIRTY, JDOHelper.getObjectState(pojo));
commitTxn();
assertEquals(ObjectState.HOLLOW_PERSISTENT_NONTRANSACTIONAL, JDOHelper.getObjectState(pojo));
Entity e = ds.get(KeyFactory.createKey(DetachableJPA.class.getSimpleName(), pojo.getId()));
assertEquals("not yar", e.getProperty("val"));
assertEquals(differentNow, e.getProperty("date"));
}