3 Replies Latest reply on Nov 4, 2008 2:55 PM by gjeudy

    When to use @Stateless

    nicolasc

      I everybody.


      I have a question, that I can not find anywhere. I do not understand the diference between


      @Stateless



      and


      @Scope(ScopeType.Stateless)


      .



      I Already notice that one is from ejb and the other is from seam, but i don't see the diference between both of them. Will seam handle the components in a different way? Which one should i use in a DAO?


      Thanks

        • 1. Re: When to use @Stateless
          thejavafreak

          @Stateless is for EJB. If you want to decouple your DAO from SLSB, then you don't put @Stateless on your DAO.

          • 2. Re: When to use @Stateless
            nicolasc

            Thank you for your reply.


            But again, I still don't see the diference: Will both of the annotations make the compoment a Stateless component? or is the behavior in some way different?


            Thanks
            Nicolas

            • 3. Re: When to use @Stateless
              gjeudy

              Both annotations will make the component stateless but @Stateless is interpreted by the EJB container for EJB3 beans and @Scope(ScopeType.Stateless) is interpreted by Seam container for seam managed beans. There it doesnt make sense to put both on the same POJO (no matter if its an EJB or a Java bean), if I were you I would choose one and stick to it.


              If you don't use EJB3 on your project then the choice is easy.