public void doEmbeddedChangeTest2(boolean newPC, int before, int after) {
deleteAll(EmbeddedOwnerPC.class);
deleteAll(EmbeddedPC.class);
OpenJPAEntityManager pm = getPM();
startTx(pm);
EmbeddedOwnerPC pc = newEmbeddedOwnerPC();
EmbeddedPC embed = new EmbeddedPC();
embed.setIntField1(1000);
pc.setStringField("orig");
pm.persist(pc);
pc.setEmbedded(embed);
Object oid = pm.getObjectId(pc);
if (!newPC) {
endTx(pm);
endEm(pm);
pm = getPM();
startTx(pm);
pc = (EmbeddedOwnerPC) pm.find(EmbeddedOwnerPC.class, oid);
}
for (int i = 0; i < before; i++) {
pc.getEmbedded().setIntField1(i);
pm.setSavepoint("b" + i);
}
pm.setSavepoint("test");
pc.getEmbedded().setIntField1(2000);
for (int i = 0; i < after; i++) {
pc.getEmbedded().setIntField1(i * -1);
pm.setSavepoint("a" + i);
}
pm.rollbackToSavepoint("test");
assertNotNull(pc.getEmbedded());
if (before == 0)
assertEquals(1000, pc.getEmbedded().getIntField1());
else
assertEquals(before - 1, pc.getEmbedded().getIntField1());
endTx(pm);
endEm(pm);
}