Distributed Transactions   «Prev 

Transactions that are managed through Entity Beans

SessionContext and the save() method
SessionContext and the save() method

Line 09Using the SessionContext method getUserTransaction(), the program gets the UserTransaction object and stores its reference in ut.
Line 11 and 12This line verifies that there is no current transaction context using getStatus() method. The return is compared to the STATUS_NO_TRANSACTION class constant. If there is a transaction, the program throws a CustomerException.
Line 13 and 14 Begin a transaction within a try-catch block.
Line 17 The actual code to update the state of one or more recoverable resources would be inserted here.
Line 18 and 19 If any problem was discovered then the transaction will be rolled back.
Line 21 The transaction manager was asked to commit the transaction.

Business Object Architecture

The Business Object Architecture contains the components that implement the business entities in the system. Each of these components manages the data and business logic associated with a particular business entity. This includes the persistence of that object's data, typically to a relational database. This database access can be implemented by the container in the case of CMP (Container-Managed Persistence) Entity Beans or by the developer in the case of BMP (Bean-Managed Persistence) Entity Beans or regular Java classes. In the last two cases, in which the developer does the work, it is a best practice to isolate the database access into a separate data-access layer. If there is any data access outside of the business object model, this should also be included in this layer. This includes database queries that are run in order to retrieve read-only data for presentation to the user.
In the bank application, a business object could represent entities such as a customer, a bank account, or even an individual transaction on the bank account such as a withdrawal. These business objects can be implemented either as Java classes, Entity Beans, or some combination of the two. The persistence of each business object is abstracted out to the extent possible so that separate data objects, persistence frameworks, or Container-Managed Persistence services can be used to have the object data persist in the database.