-
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
A boolean property should be able to have two getters: isX() and getX() #906
Comments
Thank you for the report, @admxiii ! I have committed the fix. For future reference, here is the stack trace:
|
I re-tested with the snapshot and it is working now. Thank you for the quick response! I am now able to remove a ton of useless is* methods on my groovy objects. |
Thanks for the quick check! Glad to hear it's working =) |
pulllock
pushed a commit
to pulllock/mybatis-3
that referenced
this issue
Oct 19, 2023
…x() and getXxx() getter methods.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Groovy object properties follow the javabean spec for boolean, which allows for both a get* and an is* method to appear on the same object. Mybatis complains this doesn't follow the javabean spec which isn't entirely true. I know you can use Boolean to get around the get/is issue or define your own getter which stops groovy from building the pair, but the strange part is that this field is not even used by mybatis, its just a helper boolean internal to the object, but mybatis still validates the entire object whether the field is used or not in a resultmap.
could this rule be relaxed to allow the official javabean spec to not throw an error?
from oracle:
8.3.2 Boolean properties
In addition, for boolean properties, we allow a getter method to match the pattern:
public boolean is();
This “is” method may be provided instead of a “get” method,
or it may be provided in addition to a “get” method.
In either case, if the “is” method is present for a boolean property then we will
use the “is” method to read the property value.
heres the code in question that throws the error on a valid javabean.
The text was updated successfully, but these errors were encountered: