Spring Core

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
Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

2 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

2 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

2 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

2 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

2 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

2 years ago