}
private Recipe detachRecipe(Recipe r) {
Recipe detachedRecipe = new Recipe();
detachedRecipe.setId(r.getId());
detachedRecipe.setTitle(r.getTitle());
Iterator<RecipeIngredient> it = r.getRecipeIngredients().iterator();
while (it.hasNext()) {
RecipeIngredient ri = it.next();
Ingredient i = new Ingredient();
i.setId(ri.getIngredient().getId());
RecipeIngredient detachedRi = new RecipeIngredient(i,
ri.getAmount());
detachedRecipe.addRecipeIngredient(detachedRi);
}
return detachedRecipe;
}