}
private void clearDependentOfDetachedTest(boolean mapped) {
deleteAll(DependentFieldsPC.class);
DependentFieldsPC owner = new DependentFieldsPC();
for (int i = 0; i < 2; i++) {
DependentFieldsPC child = new DependentFieldsPC();
if (mapped) {
owner.getDependentMappedList().add(child);
child.setOwner(owner);
} else
owner.getDependentInverseKeyList().add(child);
}
OpenJPAEntityManager pm =
(OpenJPAEntityManager) currentEntityManager();
startTx(pm);
pm.persist(owner);
endTx(pm);
Object oid = pm.getObjectId(owner);
assertEquals(3,
((Extent) pm.createExtent(DependentFieldsPC.class, true))
.list().size());
endEm(pm);
pm = (OpenJPAEntityManager) currentEntityManager();
owner = (DependentFieldsPC) pm.find(DependentFieldsPC.class, oid);
if (mapped)
assertEquals(2, owner.getDependentMappedList().size());
else
assertEquals(2, owner.getDependentInverseKeyList().size());
DependentFieldsPC detached = (DependentFieldsPC) pm.detach(owner);
endEm(pm);
if (mapped) {
assertEquals(2, detached.getDependentMappedList().size());
detached.getDependentMappedList().clear();
} else {
assertEquals(2, detached.getDependentInverseKeyList().size());
detached.getDependentInverseKeyList().clear();
}
pm = (OpenJPAEntityManager) currentEntityManager();
startTx(pm);
owner = (DependentFieldsPC) pm.merge(detached);