0 Replies Latest reply on Jul 26, 2007 2:43 AM by kooudy

    Stafull session bewn - set new reference

    kooudy

      I have a question:

      I have statefull bean:

      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("hotelSearch")
      public class HotelSearch implements HotelSearchLocalIF {
       @DataModelSelection
       private Hotel hotel;
      
       @DataModel
       private List<Hotel> hotelList;
      
       /**
       * Set new hotel.
       */
       public void setHotel(Hotel hotel) {
       this.hotel = hotel;
       }
      
       private void logHotel() {
       log.debug(this.hotel);
       }
      
      }


      I call
      hotel.setHotel(newHotel)
      from another stateless bean to set new detail.

      Then I call
      logHotel()
      but there is original hotel logged
      (which was in variable hotel before setting new one).
      It looks like method
      setHote(hotel)
      sets new detail only for
      setHotel()
      method duration. But after this method ends, original hotel is injected.

      When I want to change hotel, I have to change attributes of hotel, but not whole instance (reference):

      public void setHotel(Hotel hotel) {
      // this.hotel = hotel; //not works, after methodends, there is original hotel injected
      
       //ne approach to update hotel detail
       this.hotel.setId(hotel.getId);
       this.hotel.setName(hotel.getName);
       ...
       }


      Can I force HotelSearch to set new hotel reference for HotelSearch?

      I have met this several times and I don't now the right solution.

      I have tried the same with @In and behaviour is similar.