Explain the similarities and differences between Spring Declarative transactions and EJB CMT(Container Managed Transactions).
Explain the similarities and differences between Spring Declarative transactions and EJB CMT(Container Managed Transactions).
The basic functions of both these transaction framework is the same. Both of them allow transaction to be applied at a method level and setRollbackOnly to be called within the transaction context to rollback. However Spring framework is far more versatile due to following reasons:
a) Spring declarative transactions can be applied to any class whereas EJB CMT can be applied only on EJBs
b) EJB CMT can only work with JTA whereas Spring can work with JDBC, JPA, Hibernate etc.
c) Spring framework allows declarative rollback rules whereas this can only be done programmatically in EJB CMT.
However, Spring framework does not support propagation of transactions across remote calls. This can be achieved only through EJB CMT.