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
Nested target properties uses same method for different mappings #1148
Comments
Until the bug is resolved one can use a mapper like: @Mapper
public interface MyMapper {
@Mappings({
@Mapping(source = "dto", target = "sender", qualifiedByName = "sender"),
@Mapping(source = "dto", target = "recipient", qualifiedByName = "recipient")
})
Entity toEntity(Dto dto);
@Named("sender")
@Mapping(source = "senderId", target = "id")
Client toClient(Dto dto);
@Named("recipient")
@Mapping(source = "recipientId", target = "id")
Client toClientRecipient(Dto dto);
} @sjaakd, @agudian, @gunnarmorling this looks a bit complex to fix (if we want to reuse methods). We do this recursively ans when we reach the second level we have lost everything until there... Do you have some suggestion. |
I thought a mapping method is characterized by its signature (excluding the name) and its mappings. Mapping |
If by mappings you mean the I think that I found a way for this, we just have to pass the |
…pping are considered in the equals of a PropertyMapping
@sjaakd thanks for the comment, it inspired me for the solution :) |
A workaround for going live with 1.2.0.CR1 would be to raise a compile error if something like this can occur, so not to generate a wrong code |
…pping are considered in the equals of a PropertyMapping
…ptions are restricted to the defined mappings
…ptions are restricted to the defined mappings
…ptions are restricted to the defined mappings
…e restricted to the defined mappings
It comes from this Stack Overflow question.
In a nutshell:
Generates:
It should generate 2
dtoToClient
methods instead of one. We most probably need to extend the thePropertyMapping
to have the nested name as well and use that somehow in theequals
The text was updated successfully, but these errors were encountered: