-
Couldn't load subscription status.
- Fork 13k
Add @StatementId to support overloaded mapper methods
#1519
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
Conversation
This is a great idea, the error message like 'invlid bound statement(not found):' will not occur often.
# Conflicts: # src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java
coveralls
commented
May 3, 2021
+1. Having explicit assigned id will bring more consistence between XML and annotation based configuration, avoiding the shortcoming on usage of convention. By the way I assume even without @StatementiD it is still a good idea to have the framework still generate the internal statementId according the method name plus signature when there is overloading happens, and notify the programmer during framework startup, instead of raise error like today's framework. For backward compatible in a non-overloaded case, we can keep the id as simple as the method name.
This PR introduces a new annotation
@StatementIdto let users assign arbitrary statement ID [1].When the value is omitted, MyBatis will calculate the ID from the method signature.
e.g.
There is no documentation yet.
I haven't decided if this should be merged or not and there could be changes in the spec.
Should fix #1482 . Related to #1312 .
Any feedback is appreciated! 🙏
[1] I plan to apply more strict validation to the user-specified ID. e.g. valid characters are alphanumeric, underscore, brackets
[]and pound sign#.