// set retainvalues to false so that we can ensure that the
// data in the database is correct, and that we're not just
// testing that the JVM data is correct.
OpenJPAEntityManager pm = getPM(true, false);
startTx(pm);
ModInstanceCallbackTests a = new ModInstanceCallbackTests("foo", 10);
pm.persist(a);
ModRuntimeTest1 parent = new ModRuntimeTest1("baz", 11);
if (!before)
pm.flush();
if (persist)
pm.persist(parent);
a.setOneOne(parent);
if (before)
pm.flush();
ModRuntimeTest1 oldParent = null;
if (multi) {
oldParent = parent;
parent = new ModRuntimeTest1("newParent", 12);
if (!before)
pm.flush();
if (persist)
pm.persist(parent);
a.setOneOne(parent);
if (before)
pm.flush();
}
endTx(pm);
assertTrue("a.preStoreCalled is false", a.preStoreCalled);
assertNotNull("a.getOneOne is null", a.getOneOne());
if (!multi)
assertTrue("a.getOneOne().getStringField().equals(baz) is false",
a.getOneOne().getStringField().equals("baz"));
else {
assertTrue(
"a.getOneOne().getStringField().equals(newParent) is false",
a.getOneOne().getStringField().equals("newParent"));
// if multi, then we really should delete the baz
// parent. This isn't happening right now.
// ### should be a bug
//assertTrue (JDOHelper.isDeleted (oldParent));