public void updateHotel( Hotel hotel, String name, Blob description, Integer stars, City city, List<Room> rooms) { Session session = sessionFactory.getCurrentSession(); hotel.setName(name); hotel.setDescription(description); hotel.setStars(stars); hotel.setCity(city); hotel.setRooms(rooms); rooms.forEach(room -> room.setHotel(hotel)); session.update(hotel); }
public void createHotel( String name, Blob description, Integer stars, City city, User owner, List<Room> rooms) { Session session = sessionFactory.getCurrentSession(); Hotel hotel = new Hotel(); hotel.setName(name); hotel.setDescription(description); hotel.setStars(stars); hotel.setCity(city); hotel.setOwner(owner); hotel.setRooms(rooms); rooms.forEach(room -> room.setHotel(hotel)); session.save(hotel); }