Skip to content

Commit 68e0fe4

Browse files
committed
Fix projection method in documentation.
Also add the reason behind the wording.
1 parent 2610b7f commit 68e0fe4

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/main/asciidoc/object-mapping/projections.adoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ interface TestRepository extends CrudRepository<TestEntity, Long> { // <.>
181181
182182
List<ExtendedTestEntity> findAllExtendedEntities(); // <.>
183183
184-
List<TestEntityInterfaceProjection> findAllInterfaceProjections(); // <.>
184+
List<TestEntityInterfaceProjection> findAllInterfaceProjectionsBy(); // <.>
185185
186-
List<TestEntityDTOProjection> findAllDTOProjections(); // <.>
186+
List<TestEntityDTOProjection> findAllDTOProjectionsBy(); // <.>
187187
188188
@Query("MATCH (t:TestEntity) - [r:RELATED_TO] -> () RETURN t, COUNT(r) AS numberOfRelations") // <.>
189189
List<TestEntityDTOProjection> findAllDTOProjectionsWithCustomQuery();
@@ -195,13 +195,15 @@ interface TestRepository extends CrudRepository<TestEntity, Long> { // <.>
195195
of the extending class. The domain type of the method in question will be the extended class, which
196196
still satisfies the domain type of the repository itself
197197
<.> This method returns an interface projection, the return type of the method is therefore different
198-
from the repository's domain type. The interface can only access properties defined in the domain type
198+
from the repository's domain type. The interface can only access properties defined in the domain type.
199+
The suffix `By` is needed to make SDN not look for a property called `InterfaceProjections` in the `TestEntity`
199200
<.> This method returns a DTO projection. Executing it will cause SDN to issue a warning, as the DTO defines
200201
`numberOfRelations` as additional attribute, which is not in the contract of the domain type.
201202
The annotated attribute `aProperty` in `TestEntity` will be correctly translated to `a_property` in the query.
202203
As above, the return type is different from the repositories' domain type.
204+
The suffix `By` is needed to make SDN not look for a property called `DTOProjections` in the `TestEntity`
203205
<.> This method also returns a DTO projection. However, no warning will be issued, as the query contains a fitting
204-
value for the additional attributes defined in the projection.
206+
value for the additional attributes defined in the projection
205207

206208
TIP: While the repository in <<projections.simple-entity-repository,the listing above>> uses a concrete return type to
207209
define the projection, another variant is the use of <<projection.dynamic,dynamic projections>> as explained in the

src/test/java/org/springframework/data/neo4j/repository/query/RepositoryQueryTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,13 @@ private Stream<Arguments> params() {
490490
TestEntity.class
491491
),
492492
Arguments.of(
493-
"findAllInterfaceProjections",
493+
"findAllInterfaceProjectionsBy",
494494
true,
495495
TestEntityInterfaceProjection.class,
496496
TestEntity.class
497497
),
498498
Arguments.of(
499-
"findAllDTOProjections",
499+
"findAllDTOProjectionsBy",
500500
true,
501501
TestEntityDTOProjection.class,
502502
TestEntity.class
@@ -602,9 +602,9 @@ Optional<TestEntity> findByDontDoThisInRealLiveNamed(@Param("location") org.neo4
602602

603603
Mono<Slice<TestEntity>> findAllByNameStartingWith(String name, Pageable pageable);
604604

605-
List<TestEntityInterfaceProjection> findAllInterfaceProjections();
605+
List<TestEntityInterfaceProjection> findAllInterfaceProjectionsBy();
606606

607-
List<TestEntityDTOProjection> findAllDTOProjections();
607+
List<TestEntityDTOProjection> findAllDTOProjectionsBy();
608608

609609
List<ExtendedTestEntity> findAllExtendedEntities();
610610

0 commit comments

Comments
 (0)