Exemplo n.º 1
0
  @Override
  @Transactional(propagation = Propagation.MANDATORY)
  public void deleteIngredientFromAllDishes(Ingredient ingredient) {
    List<Dish> result = new ArrayList<>();
    for (Dish dish : findAll()) {
      for (Ingredient i : dish.getIngredients()) {
        if (ingredient.equals(i)) {
          result.add(dish);
        }
      }
    }

    for (Dish dish : result) {
      deleteIngredient(ingredient, dish);
    }
  }
Exemplo n.º 2
0
 private void deleteIngredient(Ingredient ingredient, Dish dish) {
   dish.getIngredients().remove(ingredient);
   sessionFactory.getCurrentSession().saveOrUpdate(dish);
 }