diff --git a/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/domain/ArticleDTO.java b/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/domain/ArticleDTO.java index 4c480bf5f..272d6d75a 100644 --- a/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/domain/ArticleDTO.java +++ b/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/domain/ArticleDTO.java @@ -1,9 +1,6 @@ package com.example.demo.readreplica.domain; -import static com.example.demo.readreplica.domain.CommentDTO.convertToComment; - import com.example.demo.readreplica.entities.Article; -import com.example.demo.readreplica.entities.Comment; import java.time.LocalDateTime; import java.util.List; @@ -16,11 +13,7 @@ public record ArticleDTO( public Article convertToArticle() { Article article = new Article().setAuthored(authored).setTitle(title).setPublished(published); - commentDTOs.forEach( - commentDTO -> { - Comment comment = convertToComment(commentDTO); - article.addComment(comment); - }); + commentDTOs.stream().map(CommentDTO::convertToComment).forEach(article::addComment); return article; } }