From 5d293c48c341b2cb77978470b386e7e61609c369 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 20 Mar 2023 10:08:03 +0100 Subject: [PATCH] Polishing. Tweak wording. See #2794 Original pull request: #2794 --- src/main/asciidoc/repository-projections.adoc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/asciidoc/repository-projections.adoc b/src/main/asciidoc/repository-projections.adoc index d2340916d..59d4e7765 100644 --- a/src/main/asciidoc/repository-projections.adoc +++ b/src/main/asciidoc/repository-projections.adoc @@ -235,14 +235,16 @@ The following example shows a projecting DTO: .A projecting DTO ==== -[source, java] +[source,java] ---- record NamesOnly(String firstname, String lastname) { } ---- ==== -Records are ideal DTOs since they adhere to value semantics (all fields are private final, `equals(…)` and `hashCode()` are provided by default), but you are free to use any class with a constructor listing the fields to be retrieved. +Java Records are ideal to define DTO types since they adhere to value semantics: +All fields are `private final` and ``equals(…)``/``hashCode()``/``toString()`` methods are created automatically. +Alternatively, you can use any class that defines the properties you want to project. ifdef::repository-projections-trailing-dto-fragment[] include::{repository-projections-trailing-dto-fragment}[]