My session beans call other bean methods within a transaction. Using bean-managed transactions, how should I take care of commit and rollback ?

Siva Visveswaran

There are two steps here:

1. Coding step:

   public class exBean implements SessionBean { 
   EJBContext ec; 
   javax.transaction.UserTransaction utxn;
   .
   .
   .
   utxn = ec.getUserTransaction();
   utxn.begin();

   // do all your txn stuff 
   // getting DB connections, updates, other bean methods, etc.
   .
   .
   utxn.commit();
}

Note you have to begin a txn before opening dB connections and close connections before committing.

2. Deployment step:

- Your app server must support a JTS for distributed txns. Most do.

- Verify there is no conflict with the bean transaction properties in calling beans.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact