🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Relationships and Transactions: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Listing 50 enrolments runs 1 query for the enrolments and 50 more for their courses. What is this called?
  2. Q2. By default, @Transactional rolls back when the method throws…
  3. Q3. A @Transactional method is called from another method in the same class. What happens?
  4. Q4. Why model Student ↔ Course with an Enrollment entity instead of @ManyToMany?
  5. Q5. What causes LazyInitializationException?
  6. Q6. What is the default fetch type of @ManyToOne if you do not set one?
  7. Q7. What does readOnly = true on @Transactional tell Spring and the database?
  8. Q8. A service method declares throws IOException and throws one. With a plain @Transactional, what happens?
  9. Q9. Two requests both see "1 seat left" at the same moment. Which is a real fix?
  10. Q10. Why does the Enrollment table also have a unique constraint on (student, course)?