DATAMONGO-2041 - Apply field restriction to DTO projections.

We now derive field projections for DTO projections if the field projection document is unrestricted.

Original pull request: #591.
This commit is contained in:
Christoph Strobl
2018-08-08 12:19:32 +02:00
committed by Mark Paluch
parent 4f9c0fa6b3
commit 016892085c
7 changed files with 126 additions and 55 deletions

View File

@@ -1745,7 +1745,11 @@ List<Jedi> all = ops.find(SWCharacter.class) <1>
<2> Resulting documents are mapped into `Jedi`.
====
TIP: You can directly apply <<projections>> to result documents by providing the `interface` type with `as(Class<?>)`.
TIP: You can directly apply <<projections>> to result documents by providing the target type via `as(Class<?>)`.
NOTE: Using projections allows `MongoTemplate` to optimize result mapping by limiting the actual response to fields required
by the projection target type. This applies as long as the `Query` itself does not contain any field restriction and the
target type is a closed interface or DTO projection.
You can switch between retrieving a single entity and retrieving multiple entities as a `List` or a `Stream` through the terminating methods: `first()`, `one()`, `all()`, or `stream()`.