[jboss-user] [JBoss Seam] - Hotel Booking sample and Conversation - Why merge?

gersonk do-not-reply at jboss.com
Thu Sep 20 16:46:36 EDT 2007


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


  | @Stateful
  | @Name("hotelBooking")
  | @Restrict("#{identity.loggedIn}")
  | public class HotelBookingAction implements HotelBooking
  | {
  |    
  |    @PersistenceContext(type=EXTENDED)
  |    private EntityManager em;
  | 
  |    ...
  |    
  |    @In(required=false) @Out
  |    private Hotel hotel;
  |    
  |    @In(required=false) 
  |    @Out(required=false)
  |    private Booking booking;
  |      
  |    ...
  |    
  |    @Begin
  |    public void selectHotel(Hotel selectedHotel)
  |    {
  |       hotel = em.merge(selectedHotel);
  |    }
  |    
  |    
  |    @End
  |    public void confirm()
  |    {
  |       em.persist(booking);
  |       facesMessages.add("Thank you, #{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
  |       log.info("New booking: #{booking.id} for #{user.username}");
  |       events.raiseTransactionSuccessEvent("bookingConfirmed");
  |    }
  |    
  |    ...
  | }
  | 

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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086920#4086920

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086920



More information about the jboss-user mailing list