4 Replies Latest reply on Sep 28, 2007 6:24 AM by Pete Muir

    Question of the day: Stateless Session Beans

    Thomas Gerhards Newbie

      Hi,

      Certainly Stateless Session Beans are usually used to call its methods from clients like Stateful Session Beans. The method returns and that's it, the Stateless SB will not remember anything. In Seam you would normally not use a Stateless SB with bijection. However the following simplified Stateless SB that outjects a book works well for me. All instance variables are overwritten with each call of its only method. As Stateless SBs are 1) cached and pooled and 2) synchronized I believe this is 1) faster than a Stateful SB and 2) does not mix up data for concurrent users.

      Could you please correct me if I'm wrong?

      @Stateless
      @Name("bookDetails")
      public class BookDetailsAction implements BookDetails {
      
       @RequestParameter
       String bookid;
      
       @Out(required=false)
       private Book book;
      
       @PersistenceContext
       private EntityManager em;
      
       @Factory("book")
       public void findBook() {
       book = em.find(Book.class, id);
       }
      
      }