2V0-72.22PSE · Question #57
Which of the following transaction propagation behaviour will create a new transaction if one does not already exist?
The correct answer is C. REQUIRED D. NESTED. REQUIRED and NESTED both create a new transaction when none exists, making C and D correct. REQUIRED (the Spring default) either joins an existing transaction or starts a fresh one - it always guarantees transactional context. NESTED similarly creates a new transaction when…
Question
Which of the following transaction propagation behaviour will create a new transaction if one does not already exist?
Options
- ASUPPORTS
- BMANDATORY
- CREQUIRED
- DNESTED
How the community answered
(27 responses)- A4% (1)
- B11% (3)
- C85% (23)
Explanation
REQUIRED and NESTED both create a new transaction when none exists, making C and D correct. REQUIRED (the Spring default) either joins an existing transaction or starts a fresh one - it always guarantees transactional context. NESTED similarly creates a new transaction when none exists, but when one does exist, it creates a nested transaction using a savepoint, allowing partial rollback.
SUPPORTS (A) is wrong because it runs non-transactionally when no transaction is present - it supports an existing one but never creates one. MANDATORY (B) is the opposite extreme: it requires a transaction to already exist and throws an IllegalTransactionStateException if none does.
Memory tip: Think of the names literally - REQUIRED means "a transaction is required, so I'll make one if needed." MANDATORY means "you are mandated to provide one yourself." SUPPORTS means "I'll go either way." If you can remember that MANDATORY demands a pre-existing transaction while REQUIRED creates one when needed, the rest falls into place.
Topics
Community Discussion
No community discussion yet for this question.