Lazy Versus Eager Loading Strategies for JPA 2.1
summary
Shows concrete JPA 2.1 fixes and gotchas: JPQL/native value-object projections and DB aggregation beat loading full entities in a 100,000-employee benchmark (simple select is ~5x slower; join fetch faster; aggregation fastest). Demonstrates Hibernate quirks: reading a Hydra collection does one select then on commit issues an extra select plus one delete and three inserts because an unmodifiable wrapper breaks identity checks, while EclipseLink/DataNucleus do one select and OpenJPA fails. Adding one Tree to a Forest can trigger collection recreation producing 10,000+ extra inserts unless mappings and inverse-side use are changed. Recommends entity graphs and provider-specific Hibernate batch-size for large collections.
AI-written summary · about
chapters (30)
- 0:00Introduction
- 1:39Outline
- 2:21Databases
- 3:40Hibernate
- 7:42ReadOnly Operations
- 8:25Unmodifiable Collection
- 9:52Lessons Learned
- 11:20What we learned
- 12:02I love JPA
- 12:52Typical use cases
- 14:34Mapping
- 16:57Aggregation
- 17:42Performance
- 19:11Problem
- 20:22Solution
- 23:26Logging Strategies
- 24:20Network Latency
- 25:02Lazy Loading Strategy
- 26:04Large Objects
- 26:55Database
- 33:56Set semantics
- 35:41Inverse relationships
- 37:41Eclipselink
- 38:02JPA Provider
- 38:49Dynamic Execution Path
- 39:30Entity Graph
- 39:50Annotations
- 41:28Advantages
- 42:31Silver Bullet
- 42:55Use Cases
related talks
58mCause of Death: Hibernate.
42mJPA - Beyond copy-paste
46mMastering JPA Performance
47mWhen ORM Becomes OMG: Performance Pitfalls in JPA and Friends
44mPerformance oriented Spring Data JPA & Hibernate
01h 05mJPA Puzzlers (+Hibernate and Spring)
49mPerformance oriented Spring Data JPA & Hibernate
44mORM Insights - How not to hurt yourself?
