Java Interview Preparation
Transaction Management Interview Questions
Transactional proxies, propagation, isolation, rollback, and distributed transactions.
Transaction Management Interview Focus
Transactional proxies, propagation, isolation, rollback, and distributed transactions.
Interview questions
1. What is transaction management in Spring Boot? Beginner
A transaction groups database operations into one unit of work. Spring starts, commits, or rolls back the transaction through a transaction manager, usually around a service method.
2. How does @Transactional work internally? Advanced
@Transactional is usually applied through a Spring proxy. Calls coming through the proxy receive transaction behaviour; private methods and calls from one method to another in the same object bypass that proxy.
3. Where should @Transactional be used? Intermediate
Transaction management protects data consistency by grouping related database operations into one unit of work. Start with the definition, understand which problem it solves, and then apply it in a small example. In an interview, explain the normal use, the main trade-off, and one practical mistake to avoid.
4. What are transaction propagation types? Advanced
Propagation defines how a method joins or creates a transaction. REQUIRED is the default: it joins an existing transaction or creates one when none exists. Other modes include REQUIRES_NEW, SUPPORTS, and NESTED.
5. What is the default propagation type? Intermediate
Propagation defines how a method joins or creates a transaction. REQUIRED is the default: it joins an existing transaction or creates one when none exists. Other modes include REQUIRES_NEW, SUPPORTS, and NESTED.
6. What are transaction isolation levels? Advanced
Isolation controls what one transaction can see from another. Common levels are READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, and SERIALIZABLE; the database determines the usual default.
7. What is the default rollback behavior? Intermediate
By default, Spring rolls back for unchecked RuntimeException and Error, not checked exceptions. Use rollbackFor on @Transactional when a checked exception must also trigger rollback.
8. Why does @Transactional not work for private methods? Advanced
@Transactional is usually applied through a Spring proxy. Calls coming through the proxy receive transaction behaviour; private methods and calls from one method to another in the same object bypass that proxy.
9. Why does @Transactional sometimes fail during self-invocation? Advanced
@Transactional is usually applied through a Spring proxy. Calls coming through the proxy receive transaction behaviour; private methods and calls from one method to another in the same object bypass that proxy.
10. What is the difference between checked and unchecked exceptions in transaction rollback? Advanced
By default, Spring rolls back for unchecked RuntimeException and Error, not checked exceptions. Use rollbackFor on @Transactional when a checked exception must also trigger rollback.
11. How do you configure rollback for checked exceptions? Intermediate
By default, Spring rolls back for unchecked RuntimeException and Error, not checked exceptions. Use rollbackFor on @Transactional when a checked exception must also trigger rollback.
12. What is a read-only transaction? Intermediate
A read-only transaction expresses that the code should not modify data. It can allow optimizations, but it is not a universal guarantee that the database will reject writes.
13. What is distributed transaction management? Advanced
A transaction groups database operations into one unit of work. Spring starts, commits, or rolls back the transaction through a transaction manager, usually around a service method.
14. How do you manage transactions across microservices? Advanced
A distributed transaction spans multiple resources or services. Prefer local transactions with events and patterns such as Saga or Outbox when possible; two-phase commit adds coordination and operational complexity.
How to Prepare for Java Technical Interviews
Use this Java technical interview question bank to revise core concepts and practise explaining your decisions clearly. The questions cover Java fundamentals, object-oriented programming, collections, exceptions, multithreading, Spring Boot, Hibernate, databases, and other topics used in real software development interviews.
Start with the fundamentals, then move to scenario-based questions and advanced topics. Filter questions by difficulty to build confidence gradually. A strong answer should define the concept, explain why it matters, and include a practical example when appropriate.
Continue your preparation with the Java tutorials, or explore all interview preparation tracks for managerial and company-focused questions.
