From Anti-Pattern to Tool: The Hidden Benefits of an Open Session
summary
Talk examines Spring + JPA connection-pool exhaustion caused by @Transactional tying EntityManager creation, reserving a connection, and starting a DB transaction together. It explains that OSIV is the only built-in way to share an EntityManager without opening a transaction (considered an antipattern) and presents an approach to separate and control session, connection, and transaction lifecycles so connections can be managed more precisely.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 1:13Unit tests purpose
- 2:15Code walkthrough issues
- 4:01Removing transactional
- 6:32Extra select problem
- 8:59Hibernate update limits
- 10:44Manual connection management
- 12:32OSIV anti-pattern
- 13:55Enabling OSIV
- 15:39Fixing connection pool
- 16:43Lazy loading impact
- 18:47Release connections early
- 21:32OSIM concept
- 24:40Implementing OSIM
- 27:10Custom annotations justified
- 30:17Controllers vs services mapping
- 33:45Early loading problems
- 37:11Join fetch batch issues
- 40:24ASIM benefits
- 41:50Introducing ASIM
- 43:13Q&A
