getExecutionContext().setProperty(PROP_DETACH_ON_CLOSE, true);
pm.getFetchPlan().setMaxFetchDepth(3);
testChildAtMultipleLevels(NEW_PM_START_END);
}
private void testChildAtMultipleLevels(StartEnd startEnd) throws EntityNotFoundException {
HasOneToOneChildAtMultipleLevelsJDO pojo = new HasOneToOneChildAtMultipleLevelsJDO();
Flight f1 = new Flight();
pojo.setFlight(f1);
HasOneToOneChildAtMultipleLevelsJDO child = new HasOneToOneChildAtMultipleLevelsJDO();
Flight f2 = new Flight();
child.setFlight(f2);
pojo.setChild(child);
startEnd.start();
pm.makePersistent(pojo);
startEnd.end();
startEnd.start();
pojo = pm.getObjectById(HasOneToOneChildAtMultipleLevelsJDO.class, pojo.getId());
assertEquals(f1.getId(), pojo.getFlight().getId());
assertEquals(child.getId(), pojo.getChild().getId());
assertEquals(child.getFlight(), f2);
assertNull(child.getChild());
startEnd.end();
Entity pojoEntity = ds.get(pojo.getId());
Entity childEntity = ds.get(child.getId());
Entity flight1Entity = ds.get(KeyFactory.stringToKey(f1.getId()));
Entity flight2Entity = ds.get(KeyFactory.stringToKey(f2.getId()));
assertEquals(flight1Entity.getKey(), pojoEntity.getProperty("flight_id_OID"));
assertEquals(childEntity.getKey(), pojoEntity.getProperty("child_id_OID"));
assertEquals(flight2Entity.getKey(), childEntity.getProperty("flight_id_OID"));