T R A N S A C T I O N S  
 
The first  container transaction  declares that in general all methods have transaction 
attribute  Required . The second declares that any methods with the name of 
 createCustomer  have transaction attribute  Mandatory  and the last says that the 
 createCustomer  method with parameter signature  (String, String,float)  has the 
transaction attribute  RequiresNew . 
Note: 
The  container transaction  elements in the EJB deployment descriptor are 
embedded in the  assembly descriptor  which is embedded in the root  ejb jar  
element. This means that the transaction attributes are not specified in the 
 enterprise beans  block as you maybe expect. 
Bean Managed Transactions (BMT) 
Whenever a bean needs to have more control over the transaction it has to manage the 
transactions on its own. The rules for the beans are: 
    
Entity Bean: because transactions are integrated with the Entity Beans life cycle an 
Entity Bean must be a CMT. 
    
Stateless Session Bean: because this bean cannot maintain a state between method 
calls, a transaction must be committed or rolled back before the method returns 
    
Stateful Session Bean: A transaction can spawn more than one method call. If the 
bean is called with a transaction, that transaction is suspended, and the bean 
instance own transaction (possibly none, if the bean has not started a transaction) is 
used while executing in the bean code. Often the caller must know which bean 
methods to call, and in which order, to open and close the transaction in the correct 
order. 
    
Message Driven Bean: the destination only calls one method  onMessage  and 
therefore any transaction must be started and finished within this method 
Like for clients the BMT uses an instance of a UserTransaction, which must be obtained by 
the "javax.ejb.EJBContext" and not from the JNDI server because it must be managed by 
the container. The user transaction can be started and ended as many times as necessary, 
but only a single transaction may be active at any time in any BMT bean instance. 
Note that for most cases a BMT can be replaced by redesigned CMTs that are easier to 
understand than BMTs. 
58






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

best web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved