-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Issue 652 - Parametrized include #331
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
Thank you @kmoco2am ! Looking at the test case, I think this is achievable using mybatis-velocity. What do you think? Regards, |
From my point of view: parametrized include is more understandable, flexible and predictable than columnalias directive, or something based on columnalias. |
columnalias is just an example. I wrote a new custom directive p.s. |
Thank you for pointing me to the velocity integration project - I did not know about that before. I think that Velocity can solve almost any issue because it is full templating engine. I just don't need all this functionality. Parametrized include is something missing in the whole mechanism of MyBatis statement construction by XML. Generally, I would be able to replace all , and others by Velocity. However, I don't want to add another syntax to our project just to be able to have this functionality (combining XML include and Velocity syntax). Some of the examples using Velocity for parametrized include are more complex (from syntax perspective), may be too much. |
We have discussed this addition on the dev list and decided it's a good addition to MyBatis :-) Could you please add the following changes to this PR before merging?
Thank you both for your contribution! |
…ration variables, processing simplified by using PropertyParser, more documentation added.
…is used in configuration.getVariables)
That's great it has been accepted ;-) Let me add more tests and documentation. |
I have updated test cases and also added documentation for this feature. |
Thank you very much! |
import org.apache.ibatis.parsing.XNode; | ||
import org.apache.ibatis.session.Configuration; | ||
import org.w3c.dom.Node; | ||
import org.w3c.dom.NodeList; | ||
|
||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove unused imports and 2) import each class explicitly instead of a package.
Please see some other classes for reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I have changed IDE configuration to fix that,
…oncrete exception used
Parameterized include (https://code.google.com/p/mybatis/issues/detail?id=652)
Hi, @kmoco2am It's merged. Thanks again for your contribution! I also added some tests that verify the expected behavior of this feature. Regards, |
Parameterized include (https://code.google.com/p/mybatis/issues/detail?id=652)
…ko and zh need translation.
This code changes implements static placeholders to be able to parametrize SQL fragments during parsing phase.