Skip to content

Commit d8cff52

Browse files
committed
add docs for entity graph support
1 parent 4c7384f commit d8cff52

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

docs/introduction.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ https://docs.mongodb.com/manual/tutorial/query-documents/#specify-and-conditions
2222
{ "status": "A", "qty": { "$lt": 30 } }
2323
----
2424
25-
will be translated to.footnote:[This is rought SQL code, as usually values are passed parameterized in the where condition.]:
25+
will be translated to.footnote:[This is rough SQL code, as usually values are passed parameterized in the where condition.]:
2626
[source,sql]
2727
----
2828
SELECT * FROM inventory WHERE status = "A" AND qty < 30

docs/query_specs.adoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,33 @@ Generated SQL:
404404
... where e.serial=?
405405
----
406406

407+
== Entity Graph
408+
As with any query method in Spring Data JPA, expression query methods also support entity graphs, which help control how
409+
related entities are loaded from the database. There are two types of entity graphs:
410+
411+
412+
1. Fetch Graph (`jakarta.persistence.fetchgraph`)
413+
+
414+
This graph explicitly defines which attributes should be fetched eagerly. Any attributes not listed in the graph will be
415+
fetched lazily—even if they are marked as EAGER in the entity definition.footnote:[Hibernate overrides this behaviour and load all EAGER attributes.]
416+
+
417+
[source,java]
418+
----
419+
@EntityGraph(attributePaths = {"name", "age"}, type = EntityGraphType.FETCH)
420+
List<Employee> findAll(Expressions expressions);
421+
----
422+
2. Load Graph (`jakarta.persistence.loadgraph`)
423+
+
424+
425+
This graph defines attributes that should be eagerly fetched in addition to those already marked as EAGER.
426+
Attributes not listed in the graph still follow their default fetch type.
427+
+
428+
[source,java]
429+
----
430+
@EntityGraph(attributePaths = {"department", "tasks"}, type = EntityGraphType.LOAD)
431+
List<Employee> findAll(Expressions expressions);
432+
----
433+
407434
== Operators
408435

409436
The following is the list of supported operators:

0 commit comments

Comments
 (0)