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. |
Spring Related Posts
- Spring MVC Web Tutorial
- Spring MVC Interview Questions
- MVC Design Pattern
- @ControllerAdvice annotation improvements in Spring
- @Conditional Annotation in Spring
- RestController in Spring 4 MVC Framework
- Exception Handling for REST with Spring
- What is New in Spring Framework 4.x
- Method injection with Spring using Lookup method property
- Spring MVC @Controller Annotation
- Spring MVC @RequestMapping Annotation
- Spring MVC @RequestParam Annotation
- Spring MVC ContextLoaderListener
- Spring MVC @RequestParam and @PathVariable annotations