-
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
Deeply nested (3+ levels) result map could cause IllegalArgumentException #1176
Comments
+1 I cannot understand why it has to be invoked twice.
The pending-dealing procedure is invoked after current xml mapper is parsed, but its logic is WRONG! |
If you are having a problem, please provide a test case or example project so that we can reproduce the problem. |
I cannot upload the full jar, but I can describe the case:
|
You might be surprised, but most reports without a repro do not reproduce the problem because there is a missing piece or two which looks irrelevant to the reporter. Here is a project I created based on your report and it works without an error. |
@harawata Sorry for missing some details: I invoked the mapper's method via MapperMethod (as defined in mapper interface) Here's the full test case, just a little modification based on yours. |
@harawata PR sent for check. |
For some cases, when parse the mapper xml, it may be have incompleteStatements.
The Configuration#buildAllStatements will parse them latter.
But it maybe do twice.
The method org.apache.ibatis.binding.MapperMethod.SqlCommand#resolveMappedStatement:
call the hasStatement method, the validateIncompleteStatements is true, so it will call buildAllStatements method and add the statement to mappedStatements and return true.
then call getMappedStatement, the validateIncompleteStatements is also true, it will call buildAllStatements again.
it will throw 'java.lang.IllegalArgumentException' : Mapped Statements collection already contains...
so I think the code must be:
configuration.getMappedStatement(statementId, **false**)
and I wonder, when the incompleteStatements is build success, why not clear them?
The org.apache.ibatis.session.Configuration#buildAllStatements
It says that the method recommend to be called once, but in the code, there are many place call the org.apache.ibatis.session.Configuration#getMappedStatement(java.lang.String) method, it means if it parse the mapper xml and produce the incompleteStatements, when run the code it will throw already have mapped statement exception?
The text was updated successfully, but these errors were encountered: