Skip to content

Commit 8ae4dfa

Browse files
DATAJPA-876, DATAJPA-838 - Add sample for AD-HOC entity graph.
1 parent bab3726 commit 8ae4dfa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/asciidoc/jpa.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,23 @@ public interface GroupRepository extends CrudRepository<GroupInfo, String> {
445445
----
446446
====
447447

448+
It is also possible to define _ad-hoc_ entity graphs via `@EntityGraph`. The provided `attributePaths` will be translated into the according `EntityGraph` without the need of having to explicitly add `@NamedEntityGraph` to your domain types.
449+
450+
.Using AD-HOC entity graph definition on an repository query method.
451+
====
452+
[source, java]
453+
----
454+
@Repository
455+
public interface GroupRepository extends CrudRepository<GroupInfo, String> {
456+
457+
@EntityGraph(attributePaths = { "members" })
458+
GroupInfo getByGroupName(String name);
459+
460+
}
461+
----
462+
====
463+
464+
448465
include::{spring-data-commons-docs}/repository-projections.adoc[leveloffset=+2]
449466

450467
[[jpa.stored-procedures]]

0 commit comments

Comments
 (0)