Bird
0
0

Which of the following is true about transaction management when using @DataJpaTest?

easy📝 Conceptual Q2 of 15
Spring Boot - Testing Spring Boot Applications
Which of the following is true about transaction management when using @DataJpaTest?
AEach test method runs within a transaction that rolls back after completion
BTransactions are disabled by default in <code>@DataJpaTest</code>
CTransactions must be manually started and committed in tests
DTransactions are committed automatically after each test
Step-by-Step Solution
Solution:
  1. Step 1: Recall default transaction behavior in @DataJpaTest

    Tests run inside transactions that rollback after each test to keep data clean.
  2. Step 2: Eliminate incorrect options

    Transactions are not disabled, nor committed automatically, and manual management is not required.
  3. Final Answer:

    Each test method runs within a transaction that rolls back after completion -> Option A
  4. Quick Check:

    Transactions rollback after tests = true [OK]
Quick Trick: Tests rollback DB changes automatically with @DataJpaTest [OK]
Common Mistakes:
  • Assuming transactions commit after tests
  • Thinking transactions are disabled
  • Trying to manage transactions manually

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes