/** * Saves an ingredient. Before that, it's attached to a recipe. * * @param recipe * @param ingredient */ public static Ingredient saveToRecipe(Long recipe, Ingredient ingredient) { Recipe r = Recipe.findById(recipe); if (r == null) { throw new RuokalistaException("Recipe not found."); } ingredient.recipe = r; save(ingredient); return ingredient; }
/** * Saves given ingredient. * * @param ingredient */ public static void save(Ingredient ingredient) { ingredient.save(); }