-
-
Notifications
You must be signed in to change notification settings - Fork 946
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
Mapper should not throw an error when explicitly ignoring read-only properties #1029
Comments
Could you share the definitions of your mapped beans and your mapper
definition?
|
Hum, we don't have the definition of |
public class DeckForm {
} DeckForm only declares some properties that are defined within the deck. I made sure the ones that are in the Form object have the same names, but the warning still shows up. |
That explains it. When mapping from I'm going to close this issue as it "works as designed". |
@arminnaderi, on Gitter, you mentioned that the reported unmapped properties don't have any accessor methods and that setting them to Could you please add the full declaration of |
|
@agudian Yes that is true, here is the implementation. |
@agudian, @gunnarmorling I think that the solution for #833 was wrong. If there is a I think that we shouldn't fail the compilation when a property is ignored. Maybe even implicitly ignore properties without a write accessor. @arminnaderi Your question in gitter about why you couldn't find the implemented mapper is (I think) that the mappers were not generated for your mapping due to the outputted error. |
I think we resolved that in the chat. But anyway, I think we have a bug here that needs to be fixed. I'll reopen the issue. |
Ok, but can we then first need to get a reproducer of the issue an it seems
to be something different than indicated by the original description. Is it
related to usage of `ignore()` for a non-existent target write accessor?
|
Yes it is related to properties which are ignored and have no target write accessor. However, by looking at the issue again, I do not think that it is related to what I am saying (maybe I am even wrong and it works as designed). The OP has a warning that some properties were not mapped which is correct, as his |
I'll create a reproducer... |
I can reproduce that some read-only properties are listed in the "unmapped target properties" message (we'll fix that), but I can't reproduce the @arminnaderi, could you please share the mapper with the |
@agudian Sure, one moment, I have to check my VCS. |
|
I believe what happened is that I ignored the
message appeared which seemed strange to me at the time as the properties do not need to be accessed if they are ignored. |
Okay, I'm seeing it now as well. Apperently, when only a subset of the unmapped properties is ignored, that error shows up... 😏 This is what you want to use in your application: @Mappings({
@Mapping(target = "lastUpdated", ignore = true),
@Mapping(target = "dateUploaded", ignore = true),
@Mapping(target = "rating", ignore = true),
@Mapping(target = "views", ignore = true),
@Mapping(target = "cost", ignore = true),
@Mapping(target = "image", ignore = true),
@Mapping(target = "rewardMapAmount", ignore = true),
@Mapping(target = "reviews", ignore = true),
@Mapping(target = "supportMapCount", ignore = true),
@Mapping(target = "creatureMapCount", ignore = true)
})
Deck toDeck(DeckForm form); |
Sounds good, I'll try it out. Thanks! |
I've edited the title and the description of the issue to clarify what we actually need to fix here. Remark: the maps are reported as unmapped target properties, as they could be modified using |
Thanks for all of your support guys, it is truly amazing. You all seem highly dedicated to this project. A rare sight. And MapStruct is an amazing project. |
Thanks for the nice feedback! We really appreciate that! I've pushed a fix to our 1.1 branch and our master just now. So I'll close this issue. |
Ran the command
./gradlew assemble
and the annotation processor threw these warnings. Andreas Gudian suggested that they should not do so.The unmapped properties are generated via the entities' constructors and are marked with
@Transient.
They do not contain accessor methods.Thanks for reading.
Edit by @agudian to clarify what problem we're actually trying to fix here:
Read-Only properties are already ignored automatically and don't show up as unmapped target properties. But explicitly ignoring a read-only property using
@Mapping(target=.., ignore=true)
leads to the error "property X has no write accessor" and supresses any warnings about further unmapped target properties.The text was updated successfully, but these errors were encountered: