1 Reply Latest reply on Jul 31, 2002 3:37 PM by Adrian Brock

    rollback not happening from one bean to another

    Deeps Deeps Newbie

      the scenario is like this.

      Bean B1 has a method say doProcess. Within doProcess I am calling ordinary class,say class A.. This class A in turn uses threads. Within each thread say a class C is loaded by reflection. Within class C another bean B2's method insertIntoEmployee is called. The insertIntoEmployee method does a database operation. In the try catch of the insertIntoEmployee method a explict session.setRollBackOnly is called. Please note that threads are not spawned from the bean thread

      After the method in class A returns. the bean B1 calls some other method, say updateDatabase. In method updateDatabase, a exception occurs and roll back is called. But the database operation done in method insertIntoEmployee does not rollback. WHY????

      Sorry to give you too many details in one go. Please tell me whatz wrong....

        • 1. Re: rollback not happening from one bean to another
          Adrian Brock Master

          As you have already guessed, your problem relates to
          threads.
          Transactions are associated with a thread.
          Once you start jumping between threads you are
          outside the scope of the ejb spec and the container
          cannot help you.

          If you *really* need to do this, you should look at the
          JTA spec and the TransactionManager interface.
          The transaction management and co-ordinating a
          transaction across threads becomes your responisibilty.

          Regards,
          Adrian