File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ https://docs.mongodb.com/manual/tutorial/query-documents/#specify-and-conditions
22
22
{ "status": "A", "qty": { "$lt": 30 } }
23
23
----
24
24
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.]:
26
26
[source,sql]
27
27
----
28
28
SELECT * FROM inventory WHERE status = "A" AND qty < 30
Original file line number Diff line number Diff line change @@ -404,6 +404,33 @@ Generated SQL:
404
404
... where e.serial=?
405
405
----
406
406
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
+
407
434
== Operators
408
435
409
436
The following is the list of supported operators:
You can’t perform that action at this time.
0 commit comments