Uploaded image for project: 'Spring Data REST'
  1. Spring Data REST
  2. DATAREST-885

Patch with object value omitted

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.2 (Hopper SR2)
    • Component/s: None
    • Labels:
      None

      Description

      After migrating to spring data rest 2.5.2 the PATCH operation with application/json-patch+json for object values is broken.

      Consider the following entity:

      @Entity
      public class Product implements Identifiable<Long> {
      
          @Id
          @GeneratedValue(strategy = IDENTITY)
          private Long id;
      
          private String name;
      
          @Embedded
          private Gtin gtin;
      }
      
      @Embeddable
      @Getter
      @Setter
      public class Gtin {
      
          private String type;
          private String value;
      }
      

      I try to patch with the following payload.

      [
        {
          "op":"replace",
          "path":"/gtin",
          "value":{"type":"EAN","value":"some"}
        }
      ]
      

      As a result of this operation the property to update (gtin) is null.

      org.springframework.data.rest.webmvc.json.patch.JsonLateObjectEvaluator#evaluate returns null because it receives a JsonMappingException as it tries to serialize the value json into the entity type.

      Please see this product to reproduce the issue https://github.com/mduesterhoeft/spring-data-rest-json-patch-issue

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            mduesterhoeft Mathias D
            Last updater:
            Spring Issues Spring Issues
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: