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

DomainObjectReader removes unwrapped properties

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When using the jackson @JsonUnwrapped annotation the doMerge method on the DomainObjectReader will remove the JsonNode from the iterator before the ObjectReader reads from the RootNode.

      private <T> T doMerge(ObjectNode root, T target, ObjectMapper mapper) throws Exception {
                     ...
      		for (Iterator<Entry<String, JsonNode>> i = root.fields(); i.hasNext();) {
      
      			Entry<String, JsonNode> entry = i.next();
      			JsonNode child = entry.getValue();
      
      			if (child.isArray()) {
      				continue;
      			}
      
      			String fieldName = entry.getKey();
      
      			if (!mappedProperties.hasPersistentPropertyForField(fieldName)) {
      				i.remove(); //<-- this will remove my unwrapped properties
      				continue;
      			}
                      ...
      		return mapper.readerForUpdating(target).readValue(root);
      	}
      

      When objects uses @Unwrapped in a collection this problem does not occur because Array child nodes are skipped.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              olivergierke Oliver Drotbohm
              Reporter:
              jan_vanrensbergen Jan Van Rensbergen
              Last updater:
              Mark Paluch
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: