Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
Assume that the application is using Spring transaction management which uses Spring AOP internally. Choose the statement that describes what is happening when the update1 method is called? (Choose the best answer.)
A.
There are 2 transactions because REQUIRES_NEW always runs in a new transaction.
B.
An exception is thrown as another transaction cannot be started within an existing transaction.
C.
There is only one transaction because REQUIRES_NEW will use an active transaction if one already exists.
D.
There is only one transaction initiated by update1() because the call to update2() does not go through the proxy.
Answer is D.
Based on the lecture video from Vmware's training course (Spring framework essentials> Module 9 > Configure Transaction Propagation):
The first update method will create a transaction and run in a proxy, and when the second update method is called, it will be executed within the same transaction in the same proxy.
Now you might be asking, why would it execute within the same transaction if the propagation is REQUIRES_NEW? Wouldn't it create a new transaction?
Normally yes, however, In this case, the update2() method is being called in the same class as the first update(), making it an internal call.
When the first update method was called the @Transactional annotation passed the method execution to the interceptor, which created a proxy for the transaction (Spring AOP). When the Internal call to the second update2() method was executed, it couldn't be intercepted by a new interceptor, therefore, it couldn't create its own transactional proxy, which means it cannot create a new transaction.
If you don't understand this concept right away, don't worry. I had to review the video several times and I'm still trying to wrap my head around it.
Same here. Luckily the instructor in the video did mention this and illustrated this in his slides 3:42 minutes into the video. Took me a while to filter though all the stuff.
The answer should be A. There should be two transactions. The first one will be suspended when the second one is called and once the second transaction is done, the first one will become active again.
Please refer to the Spring Docs on the topic of Transaction propagation: https://docs.spring.io/spring-framework/reference/data-access/transaction/declarative/tx-propagation.html
UPDATE: I went though the VMWare Spring Framework Essentials lecture video where they used this exact example. The answer is indeed D. Feel to stupid for my original post. Apologies for the confusion.
The option D is correct due to this article, where this case resolved -
https://www.marcobehler.com/guides/spring-transaction-management-transactional-in-depth
I think is A correct answer
Option B is incorrect because an exception is not thrown when using REQUIRES_NEW propagation.
Option C is incorrect because REQUIRES_NEW will always create a new transaction even if an active transaction is present.
Option D is also incorrect because the call to update2() does go through the proxy and the transactional behavior will be applied.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
2211094
1 week agoAncient1
11 months agoAncient1
11 months agoAzuni
10 months, 3 weeks agoAzuni
11 months, 1 week agoAzuni
11 months, 1 week agoVerixas
1 year, 2 months agorhuanca
1 year, 3 months ago