ORM Iinsights - How to Not Hurt Yourself?
summary
ORM patterns for Java with Hibernate and JPA show concrete pitfalls and fixes: dirty checking keeps a snapshot for every managed entity so dirty checking doubles memory and triggers per-field comparisons on flush; lazy associations easily create N+1 queries unless replaced by join fetch, entity graphs, or controlled batch-size; bidirectional collections cause Cartesian explosions so prefer many‑to‑one plus separate queries; enable optimistic locking with @Version optimistic locking to avoid lost updates; avoid side effects inside transactions; prefer DTO queries, Jooq or Spring Data JDBC for predictable SQL.
AI-written summary · about
chapters (9)
- 0:00Introduction and disclaimers
- 3:42Why ORM pitfalls matter
- 5:13Entity states and dirty checking
- 18:37Associations and loading strategies
- 29:23N+1 query problem explained
- 38:07Optimistic locking and aggregates
- 41:47Transaction pitfalls and best practices
- 44:21Alternatives to Hibernate JPA
- 47:40Q&A and resources
related talks
44mORM Insights - How not to hurt yourself?
47mWhen ORM Becomes OMG: Performance Pitfalls in JPA and Friends
58mCause of Death: Hibernate.
45mWhen ORM Becomes OMG: Performance Pitfalls in JPA and Friends
45mLazy Versus Eager Loading Strategies for JPA 2.1
36mORM is an Offensive Anti-Pattern
59mDoctrine ORM Good Practices and Tricks
42mJPA - Beyond copy-paste
