Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The tutorial creates an enterprise application that has an ejb module and a web module. The ejb module uses Account entity and Person entity. The Account entity has accountNumber, personId and balance attributes. The Person entity has personId, personName and address attributes. The personId in Account entity refers to personId in Person entity. The AccountBean injects EntityManagerFactory from which it creates EntityManager object. It is a stateful session bean which has Account entity object, corresponding Person entity object, EntityManager object and EntityManagerFactory object as state fields. The bean has updateAllValues(String address, String personName, double balance) method that updates Account and Person entity attributes. It has also deposit(double amount) and withdraw(double amount) methods for withdrawing and depositing the amounts to the account. In all the above mentioned methods, the EntityManager object joins the active transaction using joinTransaction() method as the its transaction-type is JTA and bean's transaction is managed by the container. The initialize(integer accountNumber) initializes the bean with Account and Person}}entity objects corresponding to the {{accountNumber sent as the parameter. Finally, the EntityManager object is closed in the destroy() method.

...