From 1ac453278c8ba490bd9e434813eb9cb756ed3d6d Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 22 Nov 2019 15:34:51 +0100 Subject: [PATCH] DATACMNS-1626 - Add attribute to projection documentation for reuse with R2DBC. We now render depending on the projection-collection attribute the appropriate return type that is used for example code to inject also alternate return types such as Mono/Flux for reactive module documentation. --- src/main/asciidoc/repository-projections.adoc | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/asciidoc/repository-projections.adoc b/src/main/asciidoc/repository-projections.adoc index ea707cba8..ff67b6ee5 100644 --- a/src/main/asciidoc/repository-projections.adoc +++ b/src/main/asciidoc/repository-projections.adoc @@ -1,3 +1,7 @@ +ifndef::projection-collection[] +:projection-collection: Collection +endif::[] + [[projections]] = Projections @@ -9,7 +13,7 @@ Imagine a repository and aggregate root type such as the following example: .A sample aggregate and repository ==== -[source, java] +[source, java, subs="+attributes"] ---- class Person { @@ -24,7 +28,7 @@ class Person { interface PersonRepository extends Repository { - Collection findByLastname(String lastname); + {projection-collection} findByLastname(String lastname); } ---- ==== @@ -54,11 +58,11 @@ Doing so lets a query method be added as follows: .A repository using an interface based projection with a query method ==== -[source, java] +[source, java, subs="+attributes"] ---- interface PersonRepository extends Repository { - Collection findByLastname(String lastname); + {projection-collection} findByLastname(String lastname); } ---- ==== @@ -256,11 +260,11 @@ To apply dynamic projections, use a query method such as the one shown in the fo .A repository using a dynamic projection parameter ==== -[source, java] +[source, java, subs="+attributes"] ---- interface PersonRepository extends Repository { - Collection findByLastname(String lastname, Class type); + {projection-collection} findByLastname(String lastname, Class type); } ---- ==== @@ -269,14 +273,14 @@ This way, the method can be used to obtain the aggregates as is or with a projec .Using a repository with dynamic projections ==== -[source, java] +[source, java, subs="+attributes"] ---- void someMethod(PersonRepository people) { - Collection aggregates = + {projection-collection} aggregates = people.findByLastname("Matthews", Person.class); - Collection aggregates = + {projection-collection} aggregates = people.findByLastname("Matthews", NamesOnly.class); } ----