Recall & Review
beginner
What is the purpose of the @Transactional annotation in Spring Boot?
The @Transactional annotation manages database transactions automatically. It ensures that a group of operations either all succeed or all fail, keeping data consistent.
Click to reveal answer
beginner
What happens if an exception occurs inside a method annotated with @Transactional?
If a runtime exception occurs, the transaction is rolled back, undoing all changes made during that transaction to keep data safe.
Click to reveal answer
intermediate
Can @Transactional be applied at both class and method levels? What is the effect?Yes. When applied at the class level, all methods inherit the transaction settings. Method-level @Transactional overrides class-level settings for that method.Click to reveal answer
intermediate
What is the default propagation behavior of @Transactional?
The default propagation is REQUIRED, meaning the method will join an existing transaction if available or start a new one if not.
Click to reveal answer
beginner
How does @Transactional improve data consistency in multi-step database operations?
It groups multiple database operations into a single transaction, so either all operations succeed or all fail together, preventing partial updates.
Click to reveal answer
What does @Transactional do when a runtime exception is thrown inside the method?
✗ Incorrect
@Transactional rolls back the transaction on runtime exceptions to keep data consistent.
Where can you apply the @Transactional annotation?
✗ Incorrect
@Transactional can be applied at both class and method levels. Method-level settings override class-level ones.
What is the default propagation behavior of @Transactional?
✗ Incorrect
The default propagation is REQUIRED, which joins an existing transaction or creates a new one if none exists.
If a checked exception occurs inside a @Transactional method, what happens by default?
✗ Incorrect
By default, checked exceptions do not cause rollback unless configured explicitly.
Why is transaction management important in database operations?
✗ Incorrect
Transaction management ensures that multiple related operations complete together, keeping data consistent.
Explain how @Transactional helps maintain data consistency in Spring Boot applications.
Think about what happens when something goes wrong during multiple database steps.
You got /4 concepts.
Describe the difference between applying @Transactional at the class level versus the method level.
Consider how you might want different transaction rules for different methods.
You got /3 concepts.