Seems that current implementation on spring-data-rest converts paths to SpEL to apply values directly on beans. See PatchOperation (v2.5.x).

Consider these options:

  • Instead of json-patch use json-merge PATCH request to send partial updates (with "application/json" or "application/merge-patch+json" content type). This will respect @JsonIgnore and other Jackson annotations and also treat associations differently.
  • You can disable "json-patch+json" completely, for example by adding a security filter
  • You can always create your custom json-patch implementation, if you still need it
  • Use application-level joining not relying on JPA, i.e. only exposing IDs of the linked entities and providing custom links in your ResourceProcessor.

Additionally, if you're using JPA and Comment.article is annotated with @ManyToOne make sure that there's no cascading on association. Even if the article object is modified with patch it won't be saved together with the comment.

Answer from Andrey Usov on Stack Overflow
🌐
Baeldung
baeldung.com › home › spring › spring web › spring mvc › using json patch in spring rest apis
Using JSON Patch in Spring REST APIs | Baeldung
May 11, 2024 - When a patch request with the application/json-patch+json “Content-Type” arrives, Spring Boot uses the default MappingJackson2HttpMessageConverter to convert the request payload to a JsonPatch instance.
🌐
Java && More
gaetanopiazzolla.github.io › java › jsonpatch › springboot › 2024 › 09 › 25 › boot-patch.html
Spring Boot JSON Patch done Right | Java && More
September 25, 2024 - This straight-to-the-point-no-...hub.com/GaetanoPiazzolla/spring-boot-patch in which · JSON Patch is applied to JPA entities in a Spring Boot Application....
🌐
Medium
medium.com › @AlexanderObregon › working-with-json-patch-vs-merge-patch-for-partial-updates-in-spring-boot-apis-57377bfe4e5a
Working with JSON Patch vs Merge Patch for Partial Updates in Spring Boot APIs
January 30, 2026 - With Spring Boot 4 and Jackson 3, a controller can still accept a patch document and apply it to a domain object by turning the object into a tree of nodes, applying the patch, then reading the modified tree back into the same type.
Top answer
1 of 2
6

Seems that current implementation on spring-data-rest converts paths to SpEL to apply values directly on beans. See PatchOperation (v2.5.x).

Consider these options:

  • Instead of json-patch use json-merge PATCH request to send partial updates (with "application/json" or "application/merge-patch+json" content type). This will respect @JsonIgnore and other Jackson annotations and also treat associations differently.
  • You can disable "json-patch+json" completely, for example by adding a security filter
  • You can always create your custom json-patch implementation, if you still need it
  • Use application-level joining not relying on JPA, i.e. only exposing IDs of the linked entities and providing custom links in your ResourceProcessor.

Additionally, if you're using JPA and Comment.article is annotated with @ManyToOne make sure that there's no cascading on association. Even if the article object is modified with patch it won't be saved together with the comment.

2 of 2
1

There's been a recent fix in Spring Data Rest:

https://github.com/spring-projects/spring-data-rest/issues/2177

The commit that resolves this issue is:

https://github.com/spring-projects/spring-data-rest/commit/5d0687d1a1bb9a84264ecb4cd088907837c382d3

From a quick read this seems to be checking that when applying a JSON patch to an entity a check is done with Jackson that the path should be accessible (read/write).

This should prevent users from being able to specify paths in the JSON patch that aren't normally exposed through POST/GET requests that are mapped directly onto entities through Jackson. I think that if you had marked the article as readable from the comment and the title attribute as writeable then the new code should allow it. Or that's I think what org.springframework.data.rest.webmvc.json.patch.JsonPointerMapping#verify is trying to do.

So if you marked the article on the comment as not being readable through Jackson (@JsonIgnore on the getter) then JSON patch shouldn't allow the title of the article to be set through a comment. The association would still exist, just not be exposed through JSON serialization, I'm not sure if this would cause problems for your application.

The change is released in Spring Data Rest 4.0.0 which is part of Spring Data 2022.0.1 which is in Spring Boot 3.0.2.

https://github.com/spring-projects/spring-data-rest/releases/tag/4.0.0 https://github.com/spring-projects/spring-data-bom/releases/tag/2022.0.1 https://github.com/spring-projects/spring-boot/releases/tag/v3.0.2

🌐
GitHub
github.com › omlip › json-patch-example
GitHub - omlip/json-patch-example: A Spring Boot application that demonstrates the usage of PATCH Http method with tests cases
<!-- JSR-353 (JSON Processing): API --> <dependency> <groupId>javax.json</groupId> <artifactId>javax.json-api</artifactId> </dependency> Jackson module : Contains the module that enable marshalling of patch operations with ObjectMapper
Starred by 4 users
Forked by 2 users
Languages   Java 100.0% | Java 100.0%
🌐
Medium
medium.com › tuanhdotnet › techniques-to-apply-json-patch-to-jpa-entities-in-spring-boot-a-comprehensive-guide-920042930f24
Techniques to Apply JSON Patch to JPA Entities in Spring Boot: A Comprehensive Guide | by Anh Trần Tuấn | tuanhdotnet | Medium
April 5, 2025 - JSON Patch is a standard format (RFC 6902) for describing changes to a JSON document. It represents a series of operations that can be applied to modify a JSON object. These operations include add, remove, replace, copy, move, and test.
🌐
Hugomalves
hugomalves.com › a-guide-to-json-patch-integration-in-spring-apps
A Guide to JSON Patch Integration in Spring Apps
November 7, 2023 - The Jackson Object mapper isn't capable of serializing/deserializing the new types defined in JSR-353/JSR-374, like the JsonValue and JsonStructure. To configure Jackson for these new types we must first add the following dependency to the project: compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr353', version: '2.10.2' Then we need to create a custom ObjectMapper bean and register the Jackson JSR-353 datatype as a module. In Spring we can create a configuration class to define a new bean:
Find elsewhere
🌐
YouTube
youtube.com › alex gutjahr | tech tutorials
How To JSON Patch in REST Controller and Spring Boot 3 - YouTube
Hey friends! JSON Patch is a standard for describing changes to a JSON resource. It's a simple way to perform updates without having to send the whole docume...
Published   November 27, 2023
Views   900
🌐
GitHub
github.com › cassiomolin › http-patch-spring
GitHub - cassiomolin/http-patch-spring: Using HTTP PATCH in Spring. · GitHub
Alternatively, we could simply annotate the method with @Valid and Bean Validation will take care of performing the the validation on the returned value (the Spring bean may need to be annotated with @Validated to trigger the validation): @Valid public <T> T patch(JsonPatch patch, T targetBean, Class<T> beanClass) { // Convert the Java bean to a JSON document JsonStructure target = mapper.convertValue(targetBean, JsonStructure.class); // Apply the JSON Patch to the JSON document JsonValue patched = applyPatch(patch, target); // Convert the JSON document to a Java bean and return it return mapper.convertValue(patched, beanClass); }
Starred by 41 users
Forked by 11 users
Languages   Java
🌐
Cassiomolin
cassiomolin.com › programming › using-http-patch-in-spring
Using HTTP PATCH in Spring — Cássio Mazzochi Molin
November 9, 2025 - Alternatively, we could simply annotate the method with @Valid and Bean Validation will take care of performing the the validation on the returned value (the Spring bean may need to be annotated with @Validated to trigger the validation): @Valid public <T> T patch(JsonPatch patch, T targetBean, Class<T> beanClass) { // Convert the Java bean to a JSON document JsonStructure target = mapper.convertValue(targetBean, JsonStructure.class); // Apply the JSON Patch to the JSON document JsonValue patched = applyPatch(patch, target); // Convert the JSON document to a Java bean and return it return mapper.convertValue(patched, beanClass); }
🌐
Medium
medium.com › @sdtapusd20 › problem-with-implementing-patch-in-spring-boot-62d5635b91ac
Problem With Implementing PATCH in Spring Boot | by Tapu Sutradhar | Medium
July 6, 2024 - For example for the above Book class if we want to update a book’s title property and totalPage property we will send the following JSON in the PATCH method as payload. ... But in the Spring controller this request body will be mapped to a new instance of Book class where alongside the title and totalPage property other properties will also populated as null.
🌐
Medium
medium.com › @ljcanales › handling-partial-updates-in-spring-boot-a-cleaner-approach-to-patch-requests-6b13ae2a45e0
Handling Partial Updates in Spring Boot with JSON Merge Patch | by Luciano Canales | Medium
April 2, 2025 - This approach aligns with the JSON Merge Patch standard defined in RFC 7386, which specifies partial updates to JSON documents. JSON Merge Patch allows clients to update only the fields they want to change while leaving others unaffected.
🌐
GitHub
github.com › GaetanoPiazzolla › spring-boot-patch
GitHub - GaetanoPiazzolla/spring-boot-patch: Applying JsonPatch to JPA Entities in a SpringBoot App in a Generic, Reusable, and Optimized Way.
This repository demonstrates how to apply JSON Patch to JPA entities in a Spring Boot Application. The approach is designed to be generic, reusable, and optimized.
Author   GaetanoPiazzolla
🌐
Java Code Geeks
javacodegeeks.com › home › enterprise java
Spring Endpoint to handle Json Patch and Json Merge Patch - Java Code Geeks
June 3, 2021 - For an endpoint that performs Json Merge patch, along the same lines, the endpoint should accept the json merge patch request body with a content type of “application/merge-patch+json”: ... All fairly straightforward thanks to the easy way that Spring Web allows to expose an endpoint and the way json-patch library provides support for the Json Patch and Json Merge Patch operations.