2 Replies Latest reply on May 29, 2008 4:57 PM by koatto

    EJB methods and transactions

    koatto

      I've the following use case :
      a webpage button invokes a SFSB method which invokes another SLSB method .
      The SLSB  updates en entity and flushes the persistencectx but
      the changes are not propagated to the db until the first method ends.
      Does the SLSB method invokation start a new transaction or everything happens in the only transaction started by the SFSB method?


      Is there a way to start a new transaction for any nested method call?


      thanks.

        • 1. Re: EJB methods and transactions
          javacoryd

          I assume your SFSB is the action handler for your web page.  Your action gets invoked in the Invoke Application phase of the JSF lifecycle and by default, Seam wraps that call in a transaction.  Your SLSB method then runs, by default, within the transaction started by Seam and isn't committed until after the phase is completed.


          You can add:
          @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)


          To your SLSB to get the behavior you want.


          Cory.

          • 2. Re: EJB methods and transactions
            koatto

            thankyou very mutch, it perfectly solved.