@Autowired
private TableRecipeIngredientDao tableRecipeIngredientDao;
public boolean addIngredient (Ingredient4Recipe i4r){
Ingredient i = new Ingredient();
i.setName(i4r.getName());
try{
i = ingredientDao.getIngredientForName(i);
}catch (Exception e){
ingredientDao.persist(i);
i=ingredientDao.getIngredientForName(i);
}finally{
i4r.setIngrdientId(i.getIngredientId());
}
TableRecipeIngredient tab= new TableRecipeIngredient();
tab.setRecipeId(i4r.getRecipeId());
tab.setIngredientId(i4r.getIngrdientId());