@ResponseBody @RequestMapping public List<Area> findAreas(String cityId) { City city = areaService.findCity(new ObjectId(cityId)); List<Area> areaList = new ArrayList<Area>(); for (Area area : city.getAreas()) { area.setCity(null); areaList.add(area); } return areaList; }
@Override public Area createArea(ObjectId cityId, String name) { City city = findCity(cityId); if (city == null) { return null; } Area area = new Area(); area.setName(name); area.setCity(city); dao.save(area); city.getAreas().add(area); dao.save(city); return area; }