@Autowired
private IDishDao dishDao;
@Transactional
public void add(Map<Integer, Integer> dishIdsToQuantities) {
OrderInfo order = new OrderInfo();
order.setUser(userDao.get(getLogin()));
order.setDate(new Date());
List<OrderContents> ordercontents = new ArrayList<OrderContents>();
for (Map.Entry<Integer, Integer> item : dishIdsToQuantities.entrySet()) {
Dish dish = dishDao.get(item.getKey());
ordercontents.add(new OrderContents(dish, item.getValue(), order));
}
order.setSpec(ordercontents);
orderDao.add(order);
}