1 Reply Latest reply on Feb 19, 2007 8:02 AM by lawrieg

    Booking example question

    lawrieg

      Hi,

      I've just been re-reading the Seam tutorial and I just wanted to check if my understanding is correct regarding the Booking example code...

      In the HotelBookingAction class the selectHotel method reads as follows:

      @Begin
      public String selectHotel(Hotel selectedHotel) {
       hotel = em.merge(selectedHotel);
       return "hotel";
      }


      Am I correct that the reason the line hotel = em.merge(selectedHotel) is necessary is because the selectedHotel object was obtained by a different entity manager?

      And, if so, does this mean that you always need to use em.merge when an object that was loaded in one class is passed as a parameter to a method in another class?

      Thanks,

      Lawrie

        • 1. Re: Booking example question
          lawrieg

          Also, is there any reason why you couldn't / wouldn't code the method as follows instead???

          @Begin
          public String selectHotel(Hotel selectedHotel) {
           hotel = em.find(Hotel.class, selectedHotel.getId());
           return "hotel";
          }