Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Code completion

Kazuki Shimizu edited this pageMar 15, 2019 ·3 revisions

In this page, we explain about code completion. The mybatis-thymeleaf does not provide a plugin for support writing a 2-way SQL because it can be replaced by a code completion feature provided by IDE.

We introduce settings example for following three IDEs.

And, we introduce following 10 templates.

Table 1. template example list
Template nameDescription

Thymeleaf standard dialect

th_if

Render 'th:if' attribute tag for mybatis-thymeleaf 2-way SQL

Example result
/*[# th:if=""]*//*[/]*/

th_unless

Render 'th:unless' attribute tag for mybatis-thymeleaf 2-way SQL

Example result
/*[# th:unless=""]*//*[/]*/

th_switch

Render 'th:switch'/'th:case' attribute tag for mybatis-thymeleaf 2-way SQL

Example result
/*[# th:switch=""]*//*[# th:case=""]*//*[/]*//*[# th:case="*"]*//*[/]*//*[/]*/

th_each

Render 'th:each' attribute tag for mybatis-thymeleaf 2-way SQL

Example result
/*[# th:each=" : ${}"]*//*[/]*/

th_each_comma_if_not_last

Render ',(comma)' when iteration object is not last element for mybatis-thymeleaf 2-way SQL

Example result
/*[(${Stat.last} ? '' : ',')]*/

th_insert

Render 'th:insert' attribute tag for mybatis-thymeleaf 2-way SQL

Example result
/*[# th:insert="~{}" /]*/

MyBatis custom dialect

mb_p

Render 'mb:p' attribute tag for mybatis-thymeleaf 2-way SQL

Example result
/*[# mb:p=""]*//*[/]*/

mb_bind

Render 'mb:bind' attribute tag for mybatis-thymeleaf 2-way SQL

Example result
/*[# mb:bind="=" /]*/

mb_like_esc_clause

Render '#likes.escapeClause()' for mybatis-thymeleaf 2-way SQL

Example result
/*[(${#likes.escapeClause()})]*/

mb_like_esc_wildcard

Render '#likes.escapeWildcard()' for mybatis-thymeleaf 2-way SQL

Example result
#likes.escapeWildcard()

IntelliJ IDEA

You can use the "Live template" feature.

<templateSetgroup="SQL-mybatis-thymeleaf">  <templatename="th_if"value="/*[# th:if=&quot;$condition$&quot;]*/&#10;  $conditionalStatement$&#10;/*[/]*/"description="Render 'th:if' attribute tag for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <variablename="condition"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="conditionalStatement"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="th_unless"value="/*[# th:unless=&quot;$condition$&quot;]*/&#10;  $conditionalStatement$&#10;/*[/]*/"description="Render 'th:unless' attribute tag for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <variablename="condition"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="conditionalStatement"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="th_switch"value="/*[# th:switch=&quot;$target$&quot;]*/&#10;  /*[# th:case=&quot;$expectedValue$&quot;]*/&#10;    $conditionalStatement1$&#10;  /*[/]*/&#10;  /*[# th:case=&quot;*&quot;]*/&#10;    $conditionalStatement2$&#10;  /*[/]*/&#10;/*[/]*/"description="Render 'th:switch'/'th:case' attribute tag for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <variablename="target"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="expectedValue"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="conditionalStatement1"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="conditionalStatement2"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="th_each"value="/*[# th:each=&quot;$varName$ : ${$collection$}&quot;]*/&#10;  $repeatableStatement$&#10;/*[/]*/"description="Render 'th:each' attribute tag for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <variablename="varName"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="collection"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="repeatableStatement"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="th_each_comma_if_not_last"value="/*[(${$varName$Stat.last} ? '' : ',')]*/"description="Render ',(comma)' when iteration object is not last element for mybatis-thymeleaf 2-way SQL"toReformat="true"toShortenFQNames="true">    <variablename="varName"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="th_insert"value="/*[# th:insert=&quot;~{$resourcePath$}&quot; /]*/"description="Render 'th:insert' attribute tag for mybatis-thymeleaf 2-way SQL"toReformat="true"toShortenFQNames="true">    <variablename="resourcePath"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="mb_p"value="/*[# mb:p=&quot;$name$&quot;]*/ $mockValue$ /*[/]*/"description="Render 'mb:p' attribute tag for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <variablename="name"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="mockValue"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="mb_bind"value="/*[# mb:bind=&quot;$name$=$value$&quot; /]*/"description="Render 'mb:bind' attribute tag for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <variablename="name"expression=""defaultValue=""alwaysStopAt="true" />    <variablename="value"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="mb_like_esc_clause"value="/*[(${#likes.escapeClause()})]*/"description="Render '#likes.escapeClause()' for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <context>      <optionname="SQL"value="true" />    </context>  </template>  <templatename="mb_like_esc_wildcard"value="#likes.escapeWildcard($target$)"description="Render '#likes.escapeWildcard()' for mybatis-thymeleaf 2-way SQL"toReformat="false"toShortenFQNames="true">    <variablename="target"expression=""defaultValue=""alwaysStopAt="true" />    <context>      <optionname="SQL"value="true" />    </context>  </template></templateSet>

Eclipse

You can use the "Templates" feature.

<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render 'th:if' attribute tag for mybatis-thymeleaf 2-way SQL"enabled="true"name="th_if">/*[# th:if="${condition}"]*/  ${conditionalStatement}/*[/]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render 'th:unless' attribute tag for mybatis-thymeleaf 2-way SQL"enabled="true"name="th_unless">/*[# th:unless="${condition}"]*/  ${conditionalStatement}/*[/]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render 'th:switch'/'th:case' attribute tag for mybatis-thymeleaf 2-way SQL"enabled="true"name="th_switch">/*[# th:switch="${target}"]*/  /*[# th:case="${expectedValue}"]*/    ${conditionalStatement}  /*[/]*/  /*[# th:case="*"]*/    ${conditionalStatement}  /*[/]*//*[/]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render 'th:each' attribute tag for mybatis-thymeleaf 2-way SQL"enabled="true"name="th_each">/*[# th:each="${varName} : $${${collection}}"]*/  ${repeatableStatement}/*[/]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render ',(comma)' when iteration object is not last element for mybatis-thymeleaf 2-way SQL"enabled="true"name="th_each_comma_if_not_last">/*[($${${varName}Stat.last} ? '' : ',')]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render 'th:insert' attribute tag for mybatis-thymeleaf 2-way SQL"enabled="true"name="th_insert">/*[# th:insert="~{${resourcePath}}" /]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render 'mb:p' attribute tag for mybatis-thymeleaf 2-way SQL"enabled="true"name="mb_p">/*[# mb:p="${name}"]*/ ${mockValue} /*[/]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render 'mb:bind' attribute tag for mybatis-thymeleaf 2-way SQL"enabled="false"name="mb_bind">/*[# mb:bind="${name}=${value}" /]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render '#likes.escapeClause()' for mybatis-thymeleaf 2-way SQL"enabled="true"name="mb_like_esc_clause">/*[($${#likes.escapeClause()})]*/</template>  <templateautoinsert="true"context="org.eclipse.datatools.sqltools.editor.template.sql.generic"deleted="false"description="Render '#likes.escapeWildcard()' for mybatis-thymeleaf 2-way SQL"enabled="true"name="mb_like_esc_wildcard">#likes.escapeWildcard(${target})</template></templates>

Visual Studio Code

You can use the "User defined snippets" feature.

{"th_if": {"prefix":"th_if","body": ["/*[# th:if=\"${1:condition}\"]*/","  ${2:conditionalStatement}","/*[/]*/"],"description":"Render 'th:if' attribute tag for mybatis-thymeleaf 2-way SQL"},"th_unless": {"prefix":"th_unless","body": ["/*[# th:unless=\"${1:condition}\"]*/","  ${2:conditionalStatement}","/*[/]*/"],"description":"Render 'th:unless' attribute tag for mybatis-thymeleaf 2-way SQL"},"th_switch": {"prefix":"th_switch","body": ["/*[# th:switch=\"${1:target}\"]*/","  /*[# th:case=\"${2:expectedValue}\"]*/","    ${3:conditionalStatement}","  /*[/]*/","  /*[# th:case=\"*\"]*/","    ${4:conditionalStatement}","  /*[/]*/","/*[/]*/"],"description":"Render 'th:switch'/'yh:case' attribute tag for mybatis-thymeleaf 2-way SQL"},"th_each": {"prefix":"th_each","body": ["/*[# th:each=\"varName : ${${1:collection}}\"]*/","  ${2:conditionalStatement}","/*[/]*/"],"description":"Render 'th:each' attribute tag for mybatis-thymeleaf 2-way SQL"},"th_each_comma_if_not_last": {"prefix":"th_each_comma_if_not_last","body": ["/*[(${${1:varName}Stat.last} ? '' : ',')]*/"],"description":"Render ',(comma)' when iteration object is not last element for mybatis-thymeleaf 2-way SQL"},"th_insert": {"prefix":"th_insert","body": ["/*[# th:insert=\"~{${1:resourcePath}}\" /]*/"],"description":"Render 'th:insert' attribute tag for mybatis-thymeleaf 2-way SQL"},"mb_p": {"prefix":"mb_p","body": ["/*[# mb:p=\"${1:name}\"]*/ ${2:mockValue} /*[/]*/"],"description":"Render 'mb:p' attribute tag for mybatis-thymeleaf 2-way SQL"},"mb_bind": {"prefix":"mb_bind","body": ["/*[# mb:bind=\"${1:name}=${2:value}\" /]*/"],"description":"Render 'mb:bind' attribute tag for mybatis-thymeleaf 2-way SQL"},"mb_like_esc_clause": {"prefix":"mb_like_esc_clause","body": ["/*[(${#likes.escapeClause()})]*/"],"description":"Render '#likes.escapeClause()' for mybatis-thymeleaf 2-way SQL"},"mb_like_esc_wildcard": {"prefix":"mb_like_esc_wildcard","body": ["#likes.escapeWildcard(${target})"],"description":"Render '#likes.escapeWildcard()' for mybatis-thymeleaf 2-way SQL"}}
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp