```//Controller @PatchMapping("/comment/{id}/") ...
# spring
Copy code
    fun PatchCommentById(@PathVariable id: Long, @RequestBody comment: Comment): ResponseEntity<Comment> {
        val updatedComment = repo.save(Comment(
                id = id,
                body = comment.body,
                video_link = comment.video_link,
                image_link = comment.image_link,
        return ResponseEntity.ok(updatedComment)
how would u partial update this?
You could do something like this:
val updatedComment = Comment()
updatedComment.body = comment.body.let { it }
updatedComment.video_link = comment.video_link.let { it }
if i do it that way, it says no value passed for parameter for the first line
with jpa I would suggest to always work with attached entities, so
Copy code
val comment = repo.getById(id).apply {
  body = comment.body
return ResponseEntity.ok(repo.save(comment))
there is also some sorcery I am never sure about, but if you in a
might happen implicitly, so you would not need to write the code yourself.
otoh, I don’t think
is that simplistic. from the rfc (https://tools.ietf.org/html/rfc5789#section-2)
Copy code
With PATCH, however, the enclosed entity contains a set of instructions describing how a resource currently residing on the origin server should be modified to produce a new version.
then json-patch was created with more specs on the operation part: https://tools.ietf.org/html/rfc6902#page-4
@nathan Try not use database entities in the signature of your function. You could use a DTO or ViewModel here.
First of all, separate your entity object from the request object then you have a world of options. For example, you can create a request object similar to this (pseudocode):
Copy code
class CommentRequest(
    val body: JsonNullable<String> = JsonNullable.undefined(),
    // etc.
with the help of https://github.com/OpenAPITools/jackson-databind-nullable. You can then do this in your service:
Copy code
if (commentRequest.body.isPresent()) {
     comment.body = commentRequest.body
 // etc.