Solution | Description | When to Use |
---|---|---|
JOIN FETCH |
Explicitly fetches associated entities in the same query as the parent (JPQL/HQL). | When a specific query needs eagerly fetched associations that are otherwise lazy. |
Batch Fetching | Loads lazy associations in batches (@BatchSize annotation). Reduces N queries to N/batch_size queries. |
General optimization for lazily loaded collections accessed frequently after initial parent fetch. |
Entity Graphs | Defines a graph of objects to be fetched for a specific query, overriding default or entity-level fetching. | Complex scenarios requiring fine-grained control over fetching for specific use cases. |
Eager Fetching | Configures an association to always be loaded with the parent entity (FetchType.EAGER ). |
Cautiously, only when the associated data is always needed with the parent and the performance impact is acceptable. |
Last active
April 28, 2025 02:34
-
-
Save HuZeJi/38dd8c8f08fd2d969abdf5d763121c1e to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment