4 Replies Latest reply on May 24, 2003 3:41 AM by jbrosenberg

    Transactions and Stateless Session EJB's

    jbrosenberg

      I am new to jBoss, I was just reading the free getting started doc for 3.0....

      In several places, it suggested that method calls into a stateless session EJB must always start a new transaction at the beginning and commit or rollback the transaction before returning....

      Is that right?

      I don't quite understand why that would be a requirement? Certainly this is not the behavior in Weblogic, for instance....

      It was using the argument that because it's stateless and you can't ever get back to the same state with subsequent calls to the same ejb, that you need to commit all data before returning....This of course makes no sense if you are calling a stateless method
      from within other ejb code, from within a transaction, etc....Or if one stateless method calls another within a transaction...

      Was this just a misinterpretation on my part, or is it a recommendation? Or does the container actually force this behavior?

        • 1. Re: Transactions and Stateless Session EJB's

          I think it is referring to the session facade pattern.

          You should be able to find references to this
          on the internet.

          Regards,
          Adrian

          • 2. Re: Transactions and Stateless Session EJB's
            jbrosenberg

            Regardless of whether it's referring to a design principle based on a "pattern", my question really is trying to understand the implementation behavior....
            In the getting started doc it doesn't refer anywhere to the "facade pattern"....

            So, I'd like to know how in jBoss stateless session method calls automatically behave with transactions...

            Is it really true that it will always start a new transaction on method entry and end the transaction on method exit....

            That's all I'm trying to understand here....

            Jason

            • 3. Re: Transactions and Stateless Session EJB's
              haraldgliebe

              Hi Jason,

              this is nothing JBoss specific. You specify the transaction behaviour in the deployment descriptor (ejb-jar.xml). The valid options are defined in the EJB specification (17.6.2).
              The behaviour you're describing is obtained by the transaction attribute RequiresNew.

              Regards,

              Harald

              • 4. Re: Transactions and Stateless Session EJB's
                jbrosenberg

                Yes, of course this is my understanding of ejb in general....Just got thrown for a loop when I read the Getting Started Doc (which was a waste of time)....

                It seems to say that with Stateless Session Beans it will require a transaction to be started on method entry and terminated on exit....