Saturday 15 September 2012

EJB CMT : Transaction Rollback Does not rollback the persisted data -


  1. I have an EJB method method A () that is annotated with a transparency attribute. REQUIRES_NEW
  2. Method A () calls two EJB methods (methodB (), methodC ()) that are running on a remote server
  3. methodB () does some database inserts The law is also annotated with the transaction attribute. REQUIRED
  4. methodC () which is annotated with the transaction attribute. REQUIRED and I'm throwing some runtime exceptions to test it for transaction management.
  5. When I tested my MethodA for transaction management, I saw the following

    in the OpenEJB log,
    1. Texas Requires_New: No suspension of transaction.

    2. Texas Requires_New: Start Transactions ... gerenimo TransactionImpl ....

    3. Complete the log from the methodB exec ... Does.

    4. MethodC throws some RuntimeException

    5. Texas Requires_New: Rolling Back Transaction ...

      ============

      Although it states that the transaction is being reverted. Database saved through database AA () Records still appear in the database. I would like that database inserts should also be rolled back.

      Would you please help me understand what is wrong?

      The problem is that the methods A, B, and C are running in different transaction codes, so In your process, there are three separate and independent transactions executed in isolation.

      Each appserver defines a transaction-related context in which it is shared by EJBs positioned in the same server.

      When you make a call while running an EJB in a remote server, the current transaction is not done.

      If you want to share the same transaction on a different remote server, then you have to implement a distributed transaction.

No comments:

Post a Comment