blaze-persistence
blaze-persistence copied to clipboard
FR: Support field-EntityView deserializatin for DTOs which are non-entity views
With EntityViewAwareMappingJackson2HttpMessageConverter BP supports (de)serialization of EntityViews (currently in MVC context only).
This only works, when the actual top-level type is an EntityView such as
@EntityView
class GroupIdView {
public UserIdView member;
}
this will work for the top-level type GroupIdView and the field member of type UserIdView
When submitting an dto like
record GroupDTO (public UserIdView member){};
This will not work, since GroupDTO is not a EntityView, thus it will be handled by the generic MappingJackson2HttpMessageConverter which will fail to deserialize member since the type is an interface.
This FR suggest that we add deserializtion support for DTO's too. As discussed with @beikov this can be done by re-implementing canRead to act if it is an EV OR if call super().canRead() opts in.