Description
Nick Ryan opened DATAREST-1012 and commented
With respect to the documentation at:
it states for "PUT": Replaces the state of the target resource with the supplied request body.
When performing a PUT on a resource which contains a nested collection it invokes the method mergeForPut(...)
in DomainObjectReader.java
.
Based on the documentation I would expect:
PUT: the nested collection to be replaced rather than merged
PATCH: the nested collection to be merged
QUESTION 1: Is the documentation wrong, or the code wrong or am I misunderstanding the expected behaviour?
Secondary to this is the way this issue was encountered:
If we have a resource which contains a nested collection of polymorphic items:
e.g.
parent
has a collection of child
where each abstract child could be a concrete boy
or girl
when POSTING to modify:
parent.children[0] = boy
to:
parent.children[0] = girl
the code ends up calling mergeForPut(...)
and trying to modify a boy
instance into a girl
instance and I get a message like:
Target bean of type boy
is not of type of the persistent entity (girl
)!
QUESTION 2: What is the expected behaviour in this case or is this case not supported e.g. for a nested collection of abstract types it needs to be cleared before items of different concrete types are replaced?
Affects: 2.6 GA (Ingalls)
8 votes, 12 watchers