What is a Transaction in Spring Framework?

Nitin Nanda :

I have been reading about @EnableTransactionManagement and then @Transactional annotations which ensures that say if a transaction involves 3 DAO operations and the 3rd fails then the first 2 also rolls back. Also, it helps when concurrent threads are accessing the same method/class. However, I could not understand what exactly a Transaction is?

I have assumed from the numerous answers on StackOverflow and other places that it is an operation when data is manipulated in the Db from the Spring Boot application. Am I correct? I could not find any question on STF that asks this question.

Brendon Randall :

Yes you are correct. See this answer for a good explanation What is a database transaction?.

From the Spring point of view, the @Transactional annotation will create an AOP point cut around your method. What this essentially does, is makes sure that any DB related queries that are executed within your method, are wrapped into a Transaction and executed as a single unit of work.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=417298&siteId=1