-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Search readable property when resolving constructor arg type by name #2804
Search readable property when resolving constructor arg type by name #2804
Conversation
Hey @harawata, this introduced a regression for us, we use to have a construct like this: public void setDeviceType(String deviceTypeCode) {
if (!Text.isEmptyOrNull(deviceTypeCode)) {
this.deviceType = DeviceTypeCache.getDeviceType(deviceTypeCode);
}
}
public DeviceType getDeviceType() {
return deviceType;
} Mapper XML: <result property="deviceType" column="deviceTypeCode"/> We relied on the fact that the In the above example, the It seems to relate to this line: - javaType = metaResultType.getSetterType(property);
+ javaType = metaResultType.getGetterType(property); I'm not sure what would be the best way to resolve this, if we have to change all our entities or if we can provide some configuration option that will tell mybatis which method to use for a Also, relevant XKCD 🤣 |
Yeah...I kind of expected that (and hoped no one does that, but you know). When fixing #2192 , I stupidly thought it would be helpful if users can omit Apologies for the double post. Forgot the |
By the way, I really would like to avoid adding a new option for this. |
Haha, makes sense, I agree that adding an option for something that should
be fixed in a different way is silly.
However if we make it required I think it should be a smart 'required',
i.e: if the getter and setter type are ambiguous...
Else it would force a lot of people to update a crazy amount of code.
What do you think?
…On Wed, Mar 1, 2023, 18:19 Iwao AVE! ***@***.***> wrote:
By the way, I really would like to avoid adding a new option for this.
If I made javaType required, everyone will complain and I can take it.
What I don't tolerate is to add a stupid option...
—
Reply to this email directly, view it on GitHub
<#2804 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHEYG4HBSJJG5VXMGC6SFDWZ6AJVANCNFSM6AAAAAAUYACS5E>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
It sounds reasonable, but for your usage, |
Exactly yes, there will for sure still be some work to do on the mapper xml's, given that these are still ambiguous ;-) |
Got it. |
My 2 cents: I could live with a mandatory |
The yes that is correct, it should not change such behavior in patch release, change is going to be reverted tonight. |
Also impacted by this change, I like the suggested idea to make it required only when it's ambiguous. Alternative could be to even forbid ambiguous cases: the getter and the setter should have the correct type and it's up to the developer to either use a different type or create an extra method. |
Hello, After re-evaluating #2803 , I am going to simply revert this change. @tzie0062 , |
Result mapping java type resolution fails when the target property has different types for writing and reading. mybatis#2834
Should fix #2803
Also added more info to the error message. Related to #2787