Investigate a way for adding dialect like as 'mybatis:where' and 'mybatis:set' tag
In current feature, it does not support for appending and trimming SQL key-word(e.g. WHERE, AND, SET) like as <where> and <set> provided by xml based scripting language.
So, we need to add the no-dynamic phrase (e.g. WHERE 1 = 1, SET id = id, etc ...) before dynamic parts. I think it is easy writing but it is troublesome rule.
I hope to be enabled to write as follow:
SELECT * FROM names
/*[# mybatis:where]*/
WHERE
/*[# th:if="${firstName} != null"]*/
firstName = /*[('#{firstName}')]*/ 'Taro'
/*[/]*/
/*[# th:if="${lastName} != null"]*/
AND lastName = /*[('#{lastName}')]*/ 'Yamada'
/*[/]*/
/*[/]*/
Hi, @kazuki43zoo .
IElementModelProcessor is valid to reproduce the function of the where tag of MyBatis.
In IElementModelProcessor, it is possible to freely acquire / change the elements in the tag using IModel.
However, it is important to note that evaluation of the template is performed after all processors are executed, so it can not be determined from the evaluation result SQL whether or not the where clause is required.
I thought it was an interesting attempt, so I implemented the processor sample of the where and set tags. please refer.
https://github.com/yoshikawaa/mybatis-thymeleaf/blob/master/src/main/java/io/github/yoshikawaa/mybatis/MyBatisWhereModelProcesser.java
https://github.com/yoshikawaa/mybatis-thymeleaf/blob/master/src/main/java/io/github/yoshikawaa/mybatis/MyBatisSetModelProcesser.java
(You can clone and check the operation with JUnit.)
Regards.
@yoshikawaa Thanks for your contributing. I will refer your sample.