1 Reply Latest reply on Mar 8, 2002 7:02 AM by mausam

    EJBException not rolling back transaction

    Huy Duong Newbie


      I have a Session EJB that calls the remove() method on an Entity bean. The remove() method deletes several rows in different tables in the database (Sybase). If one of the delete fails, I catch the SQLException and throw an EJBException so the container rolls back the transaction. The problem is that any deletes that completed successfuly do not rollback leaving the DB in a bad state.

      To (kind of) replicate the problem, I intentionally throw an EJBException at the end of the ejbRemove() method, in which case all DELETE statements should rollback, but do not.

      Am I not understanding the EJB specs properly? Does anybody have an explanation and/or solution?


        • 1. Re: EJBException not rolling back transaction
          mausam Newbie


          I suggest u that 1st u check whether ur tables supports transaction if yes try following code

          UserTransaction ut = null;

          InitialContext initial = new InitialContext();
          UserTransaction ut = (UserTransaction)initial.lookup("java:comp/UserTransaction");


          ////Ur Transaction queries here


          in Exception


          may this help u