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

    EJBException not rolling back transaction

    quasar

      Hi,

      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?

      Thanks,
      Huy

        • 1. Re: EJBException not rolling back transaction
          mausamgautam

          Hi

          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");


          ut.begin();

          ////Ur Transaction queries here

          ut.commit();

          in Exception

          ut.rollback();

          may this help u

          bye

          Mausam