0

I use Spring R2DBC with Webflux and calling save() and findById() like below.

public Mono<CommentDTO> create(CommentDTO commentDTO, AuthenticatedUser authenticatedUser) {
        return commentRepository.save(Comment.builder()
                        .id(commentDTO.getId())
                        .content(commentDTO.getContent())
                        .archive(commentDTO.getArchive())
                        .build())
                        .flatMap(comment -> {
                            return commentRepository.findById(comment.getId()).map(CommentDTO::from);
                        });
    }

Because I'm using join query on findById() so I can't be returned the desired data with only save().
I wonder if there is a more effective way to find data with join query after saving the data.
Or is this not a bad way?
I'd appreciate your help.

tail
  • 105
  • 1
  • 1
  • 9

0 Answers0