Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DomainObjectReader removes unwrapped properties [DATAREST-912] #1278

Open
spring-projects-issues opened this issue Sep 28, 2016 · 1 comment
Assignees
Labels
type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 28, 2016

Jan Van Rensbergen opened DATAREST-912 and commented

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.


Issue Links:

1 votes, 3 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 28, 2016

Mark Paluch commented

DATAREST-910 deals also with nested and unwrapped properties. We could reuse WrappedProperties to address the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug
Projects
None yet
Development

No branches or pull requests

2 participants