Description
Currently, it is an error to use @MappingTarget in conjunction with @SubclassMapping.
This leads to the scenario where we can convert from a DTO into a subclass structure correctly, but cannot update that subclass structure using another DTO. This is particularly annoying in a nested structure (such as queries and subqueries).
The current workaround is to write each subclass as an update method and then use an @AfterMapping method to do the instanceof checks and call the appropriate update methods in the subclass. This is not ideal, as 'inherited' properties from the superclass will be mapped twice (causing excess database reads). In addition, we have to duplicate work.
It would be immensely helpful if the update method could inherit the @SubclassMapping annotations and perform the instanceof checks directly in the mapper. In the even the mapper could not find an appropriate subclass type, either throwing an exception or downcasting and using the current functionality would be good.