BE Study 13th
Receiving JSON body of the HTTP request 1. @RequestBody Using RequestBody, you can receive the body of the request as a JSON: Content-Type: application/json Without RequestBody, the parameter will be mapped via @RequestParam(@RequestParam is omitted). @PrePersist Problem Two ways of initializing the field of the entity. 1. public Comment( @NonNull String postId, @NonNull String authorId, String content ) { this.postId = postId; this.authorId = authorId; this.content = content; this.createdDate = LocalDate.now(); } 2. public Comment( @NonNull String postId, @NonNull String authorId, String content ) { this.postId = postId; this.authorId = authorId; this.content = content; } @PrePersist public void prePersist() { createdDate = LocalDate.now(); } The latter(2) is recommended, in terms of entity lifecycle and persistence context and DB's consistence. 3...