Programmatic transaction management is better only when a small number of tasks are involved to complete a transaction. Also in EJB world, one can use TransactionAttribute annotation to specify the TransactionAttributeType. The application server is in charge of commit and rollback. With CMT, the EJBs automatically become transactional by default. Similar to the Spring’s declarative transaction management, EJB provides the better worry-free container-managed transaction (CMT) demarcation. And of course this can be overridden by doing configuration changes to make Spring rollback the transactions on any exceptions. In the default configuration, Spring will mark a transaction for rollback in the case of Runtime Exceptions. If everything goes smoothly, the transaction will be successfully committed. The caller of one transaction actually invokes an AOP proxy where the transaction is created on the way in and committed or rolled back on the way out. Under the hood, Spring implements it via APO proxy. It is easy to use declarative transaction management in Spring by just put and into the code. All we need are some annotations and configurations. With the declarative model, developers usually don’t have to write any code related to the transaction itself. Since most of the time the transaction management logic is straightforward, most of the users prefer declarative transaction management. UserTransaction API is invented for the similar purpose of PlatformTransactionManager API in Spring.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |