endEm(em);
}
public void testMultipleFlushes ()
{
AutoIncrementPC2 pc2 = new AutoIncrementPC2 (1);
pc2.setStringField ("pc2");
pc2.setIntField (2);
AutoIncrementPC3 pc3 = new AutoIncrementPC3 (2);
pc3.setStringField ("pc3");
EntityManager em = currentEntityManager();
startTx(em);
em.persist (pc2);
em.persist (pc3);
oid2 = pc2.getId();
oid3 = pc3.getId();
em.flush ();
oid2a = pc2.getId();
oid3a = pc3.getId();
assertEquals (oid2, oid2a);
assertEquals (oid3, oid3a);
long id = pc3.getId ();
assertEquals (pc2, em.find(AutoIncrementPC2.class, oid2a));
assertEquals (pc3, em.find(AutoIncrementPC3.class, oid3a));
pc2.setStringField ("pc2a");
pc2.setIntField (3);
pc3.setStringField ("pc3a");
em.flush ();
oid2b = pc2.getId();
oid3b = pc3.getId();
assertEquals (oid2, oid2b);
assertEquals (oid3, oid3b);
assertEquals (id, pc3.getId ());
assertEquals (pc2, em.find(AutoIncrementPC2.class, oid2b));
assertEquals (pc3, em.find(AutoIncrementPC3.class, oid3b));
endTx(em);
endEm(em);
em = currentEntityManager();
startTx(em);
pc2 = em.find(AutoIncrementPC2.class, oid2b);
pc3 = em.find(AutoIncrementPC3.class, oid3b);
assertEquals ("pc2a", pc2.getStringField ());
assertEquals (3, pc2.getIntField ());
assertEquals ("pc3a", pc3.getStringField ());
assertEquals (id, pc3.getId ());
endTx(em);
endEm(em);
}