2 Replies Latest reply on Oct 20, 2006 9:34 AM by busawreck

    Transaction question, REQUIRES_NEW

    busawreck

      I have a Stateless SB with a business method (m1) for completing a series of tasks all in their own transactions, so that if task xx fails the other tasks will still complete. For each task I call a business method (m2) on the same bean with the annotation TransactionAttribute(REQUIRES_NEW).
      I would expect that when I throw (and catch) a RuntimeException in m2, it would mark my current transaction for rollback, but the transaction in m1 would not be marked for rollback. When I run my program though, I notice that after the RuntimException has been thrown (and caught) in m2, the transaction in m1 is marked for rollback, hence all calls to m2 fails aswell.
      Where am I doing/thinking wrong :).

        • 1. Re: Transaction question, REQUIRES_NEW
          atamur

           

          "busawreck" wrote:
          I have a Stateless SB with a business method (m1) for completing a series of tasks all in their own transactions, so that if task xx fails the other tasks will still complete. For each task I call a business method (m2) on the same bean with the annotation TransactionAttribute(REQUIRES_NEW).
          I would expect that when I throw (and catch) a RuntimeException in m2, it would mark my current transaction for rollback, but the transaction in m1 would not be marked for rollback. When I run my program though, I notice that after the RuntimException has been thrown (and caught) in m2, the transaction in m1 is marked for rollback, hence all calls to m2 fails aswell.
          Where am I doing/thinking wrong :).

          please provide some code

          if you have
          class sb implemets sb_remote{
          @EJB
          private sb_remote sb;
          public void m1() {
          }
          
          public void m2() {
          }
          }
          

          you should write in m1:
          sb.m2() not this.m2!

          • 2. Re: Transaction question, REQUIRES_NEW
            busawreck

            I wish I could say i didn''t use 'this.m2()', but I did .. Thank you for the help :).