A transaction is often defined as an indivisible unit of work. Transactions are used to maintain the integrity of data in business applications. A transaction can end either in a commit or in a rollback. A transaction that ends in commit will result in saving the data modifications done by its component statements. A transaction ends in rollback if any of its component statements fail. Data modifications are not saved in this case. In case of an EJB, how the beginning and ending of transactions—referred to as transaction boundaries —are set is determined by specifying whether the EJB uses container-managed or bean-managed transactions. The type of transactions used by the EJB is specified by using the transaction-type
element in the EJB deployment descriptor, or by using annotations, as discussed later in this section. The following XML fragment is an example of a session bean using container-managed transactions.
<enterprise-beans> <session> <ejb-name>HelloworldBean...