Skip to content

Commit 5d0a985

Browse files
committed
Dynamic SQL using <script> for localized files
1 parent f56f3e7 commit 5d0a985

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

src/site/es/xdoc/dynamic-sql.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,20 @@ AND title like ‘someTitle’]]></source>
157157
<p><span class="label important">NOTA</span> You can pass any Iterable object (for example List, Set, etc.), as well as any Map or Array object to foreach as collection parameter. When using an Iterable or Array, index will be the number of current iteration and value item will be the element retrieved in this iteration. When using a Map (or Collection of Map.Entry objects), index will be the key object and item will be the value object.</p>
158158
<p>Esto finaliza la discusión sobre la configuración XML y los ficheros de mapeo XML. En la sección siguiente hablaremos del API Java en detalle, de forma que puedas obtener el máximo rendimiento de los mapeos que has creado.</p>
159159
</subsection>
160+
<subsection name="script">
161+
<p>For using dynamic SQL in annotated mapper class, <em>script</em> element can be used. For example:</p>
162+
<source><![CDATA[@Update(
163+
"<script>update Author",
164+
" <set>",
165+
" <if test="username != null">username=#{username},</if>",
166+
" <if test="password != null">password=#{password},</if>",
167+
" <if test="email != null">email=#{email},</if>",
168+
" <if test="bio != null">bio=#{bio}</if>",
169+
" </set>",
170+
"where id=#{id}",
171+
"</script>")
172+
void updateAuthorValues(Author author);]]></source>
173+
</subsection>
160174
<subsection name="bind">
161175
<p>El elemento <code>bind</code> te permite crear una variable a partir de una expresion OGNL y asociarla al contexto. Por ejemplo:</p>
162176
<source><![CDATA[

src/site/ja/xdoc/dynamic-sql.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@ AND title like ‘someTitle’]]></source>
163163
<p><span class="label important">NOTE</span> collection には Iterable を実装したオブジェクト(List や Set など)の他に Map や Array を指定することもできます。collection に Iterable または Array を指定した場合、 index で指定した変数にはインデックスの数値、 item で指定した変数にはコレクション、配列の要素が格納されます。Map あるいは Map.Entry のコレクションを指定した場合は index にマップのキー、item にマップの値が格納されます。</p>
164164
<p>XML 設定ファイルと XML Mapper ファイルについての説明はここまでになります。次の章では、Java API について詳しく見ていきます。</p>
165165
</subsection>
166+
<subsection name="script">
167+
<p>For using dynamic SQL in annotated mapper class, <em>script</em> element can be used. For example:</p>
168+
<source><![CDATA[@Update(
169+
"<script>update Author",
170+
" <set>",
171+
" <if test="username != null">username=#{username},</if>",
172+
" <if test="password != null">password=#{password},</if>",
173+
" <if test="email != null">email=#{email},</if>",
174+
" <if test="bio != null">bio=#{bio}</if>",
175+
" </set>",
176+
"where id=#{id}",
177+
"</script>")
178+
void updateAuthorValues(Author author);]]></source>
179+
</subsection>
166180
<subsection name="bind">
167181
<p><code>bind</code> 要素を使うと、OGNL 式の結果を変数に格納し、その変数を SQL 文中で使用することができます。</p>
168182
<source><![CDATA[

src/site/ko/xdoc/dynamic-sql.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,20 @@ AND title like ‘someTitle’]]></source>
188188
<p><span class="label important">참고</span> 컬렉션 파라미터로 Map이나 배열객체와 더불어 List, Set등과 같은 반복가능한 객체를 전달할 수 있다. 반복가능하거나 배열을 사용할때 index값은 현재 몇번째 반복인지를 나타내고 value항목은 반복과정에서 가져오는 요소를 나타낸다. Map을 사용할때 index는 key객체가 되고 항목은 value객체가 된다. </p>
189189
<p>XML설정 파일과 XML 매핑 파일에 대해서는 이 정도에서 정리하고 다음 섹션에서는 Java API 에 대해 좀더 상세하게 살펴볼 것이다.</p>
190190
</subsection>
191+
<subsection name="script">
192+
<p>For using dynamic SQL in annotated mapper class, <em>script</em> element can be used. For example:</p>
193+
<source><![CDATA[@Update(
194+
"<script>update Author",
195+
" <set>",
196+
" <if test="username != null">username=#{username},</if>",
197+
" <if test="password != null">password=#{password},</if>",
198+
" <if test="email != null">email=#{email},</if>",
199+
" <if test="bio != null">bio=#{bio}</if>",
200+
" </set>",
201+
"where id=#{id}",
202+
"</script>")
203+
void updateAuthorValues(Author author);]]></source>
204+
</subsection>
191205
<subsection name="bind">
192206
<p><code>bind</code> 엘리먼트는 OGNL표현을 사용해서 변수를 만든 뒤 컨텍스트에 바인딩한다.
193207
예를들면 </p>

src/site/zh/xdoc/dynamic-sql.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,20 @@ AND title like ‘someTitle’]]></source>
160160
<p><span class="label important">注意</span> 你可以将任何可迭代对象(如 List、Set 等)、Map 对象或者数组对象传递给 <em>foreach</em> 作为集合参数。当使用可迭代对象或者数组时,index 是当前迭代的次数,item 的值是本次迭代获取的元素。当使用 Map 对象(或者 Map.Entry 对象的集合)时,index 是键,item 是值。</p>
161161
<p>到此我们已经完成了涉及 XML 配置文件和 XML 映射文件的讨论。下一章将详细探讨 Java API,这样就能提高已创建的映射文件的利用效率。</p>
162162
</subsection>
163+
<subsection name="script">
164+
<p>For using dynamic SQL in annotated mapper class, <em>script</em> element can be used. For example:</p>
165+
<source><![CDATA[@Update(
166+
"<script>update Author",
167+
" <set>",
168+
" <if test="username != null">username=#{username},</if>",
169+
" <if test="password != null">password=#{password},</if>",
170+
" <if test="email != null">email=#{email},</if>",
171+
" <if test="bio != null">bio=#{bio}</if>",
172+
" </set>",
173+
"where id=#{id}",
174+
"</script>")
175+
void updateAuthorValues(Author author);]]></source>
176+
</subsection>
163177
<subsection name="bind">
164178
<p><code>bind</code> 元素可以从 OGNL 表达式中创建一个变量并将其绑定到上下文。比如:</p>
165179
<source><![CDATA[

0 commit comments

Comments
 (0)