3 Replies Latest reply on Sep 23, 2007 3:21 AM by Alex Ka

    Hotel Booking sample and Conversation - Why merge?

    Gerson M Newbie

      The HotelBookingAction (SFSB) has an method that begins the long-running conversation (@Begin) called selectHotel(Hotel selectedHotel) . See below:

      public class HotelBookingAction implements HotelBooking
       private EntityManager em;
       @In(required=false) @Out
       private Hotel hotel;
       private Booking booking;
       public void selectHotel(Hotel selectedHotel)
       hotel = em.merge(selectedHotel);
       public void confirm()
       facesMessages.add("Thank you, #{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
       log.info("New booking: #{booking.id} for #{user.username}");

      The question is: why does use em.merge on 'selectedHotel'? What about em.find(Hotel.class, selectedHotel.getId())?