Nov 10, 2018


Every transaction has a beginning and an end. The process of marking the transaction boundaries is known as transaction demarcation. Transactions either commit or rollback to their initial stage. In EJB, a transaction must pass the ACID test, i.e., it must meet the following requirements:
  1. Atomicity: A transaction is an atomic unit of work. This means that in order to be in a transaction, a group of activities should succeed, or all of them should fail. If a transaction is interrupted, all previous steps within that transaction are undone. For example, while withdrawing money from an ATM, the account balance of the cardholder is checked, the money is withdrawn, and the balance is deducted. If any of these steps fail, the transaction should be rolled back as if nothing happened. 
  2. Consistency: This property of transaction refers to the behavior of data after a transaction is completed. Whether a transaction commits or rolls back, it must leave the data in a consistent state. When money is withdrawn from an ATM, the amount of money deducted from the balance must be equal to the money that the cardholder receives. 
  3. Isolation: A transaction must be performed such that it is unaffected by any other part of the system. This means the data that a transaction accesses cannot be affected by any other part of the system until the transaction is completed. This property is directly related to the consistency property, as the violation of this property may leave data in an inconsistent state. 
  4.  Durability: This property of transaction deals with data persistence. If a transaction deals with changing some data stored in a database, the results of a transaction must be reflected in the database. This ensures that the changes are not lost if the system crashes.