Content-Length: 307786 | pFad | https://github.com/mapstruct/mapstruct/issues/2946

C9 Allow @MappingTarget to be used with @SubclassMapping · Issue #2946 · mapstruct/mapstruct · GitHub
Skip to content

Allow @MappingTarget to be used with @SubclassMapping #2946

Open
@heanssgen-troy

Description

@heanssgen-troy

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.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/mapstruct/mapstruct/issues/2946

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy