Hibernate 7 introduces a Hibernate-specific @NamedEntityGraph annotation that lets you define JPA entity fetch plans using a concise text-based graph language instead of verbose nested annotation trees. The guide covers defining simple and multiple named graphs, subtype-specific subgraphs for inheritance hierarchies, map key subgraphs, runtime graph creation via GraphParser, merging multiple graphs with EntityGraphs.merge(), and applying graphs through both plain JPA EntityManager hints and Spring Data JPA's @EntityGraph annotation. Practical test examples verify each scenario.
Table of contents
1. Overview2. Setup3. Text-Based Graph Language4. Understanding @NamedEntityGraph5. Using the GraphParser6. Merging Graphs7. Using the Graphs8. Testing9. ConclusionSort: