Container Managed Transaction (CMT) on the EJB and Spring Declarative Transaction

This article is to compare the transaction management of EJB and Spring Declarative Transaction is very important on J2EE environment and usually we don’t notice them because J2EE container or POJOs lightweight framework do help our dirty work.

You could find more about Spring Transaction

 

 

EJB-CMT(Container Managed Transaction) Spring Declarative Transaction
EJB-CMT is tied with JTA. Spring Transaction is flexible, not tied any implementation, it is consistent abstraction of transaction either we could use Global Transaction or Local Transaction.
For EJB-CMT application server is required. No Application server required for Spring Managed Transaction
Container Managed Transaction apply only on the EJB specific classes. Container Managed Transaction apply only on the EJB specific classes.
EJB-CMT does not have flexible rule for rollback, First, if a system exception is thrown, the container will automatically roll back the transaction. Second, by invoking the setRollbackOnly method of the EJBContext interface, the bean method instructs the container to roll back the transaction. If the bean throws an application exception, the rollback is not automatic but can be initiated by a call to setRollbackOnly. Spring Transaction provides comprehensive support for customized rolling back. It also provide automatically rolling back in case any run time exceptions thrown not on checked exceptions.
You can not make influence to EJB CMT. You could customize the Spring Transaction with help of Spring AOP. You could make own advice for Spring Transaction.
EJB CMT provide the transaction across the remote calls. If your requirement such type then It is recommended you could EJB CMT. Spring transaction manager can not support remote calls across the servers. For this support required high end application server.

 

 

 

Previous
Next