swh:1:snp:113c758bbca8ab355325fa13c5762925d199e835
Raw File
Tip revision: 669d5b245cbe2efedbf2ae777ed633accf98e9c4 authored by Iwao AVE! on 03 July 2024, 03:06:24 UTC
Reverted to 3.5.16
Tip revision: 669d5b2
dynamic-sql.html
<!DOCTYPE html>


<!--
 | Generated by Apache Maven Doxia Site Renderer 2.0.0-M16 from src/site/ja/xdoc/dynamic-sql.xml at 03 7月 2024
 | Rendered using Apache Maven Fluido Skin 2.0.0-M8
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0-M16" />
    <meta name="author" content="Clinton Begin" />
    <meta name="author" content="Iwao AVE!" />
    <title>mybatis – MyBatis 3 | 動的 SQL</title>
    <link rel="stylesheet" href="./css/apache-maven-fluido-2.0.0-M8.min.css" />
    <link rel="stylesheet" href="./css/site.css" />
    <link rel="stylesheet" href="./css/print.css" media="print" />
    <script src="./js/apache-maven-fluido-2.0.0-M8.min.js"></script>
  </head>
  <body>
    <div class="container-fluid container-fluid-top">
      <header>
        <div id="banner">
          <div class="pull-left"></div>
          <div class="pull-right"><div id="bannerRight"><h1><a href="https://blog.mybatis.org/" class="externalLink"><img class="imageLink" src="../../images/mybatis-logo.png" alt="MyBatis logo" /> MyBatis</a></h1></div></div>
          <div class="clear"><hr/></div>
        </div>

        <div id="breadcrumbs">
          <ul class="breadcrumb">
        <li id="publishDate">最終更新: 02 4月 2024<span class="divider">|</span>
</li>
          <li id="projectVersion">バージョン: 3.5.16</li>
          </ul>
        </div>
      </header>
      <div class="row-fluid">
        <header id="leftColumn" class="span2">
          <nav class="well sidebar-nav">
  <ul class="nav nav-list">
   <li class="nav-header">Core</li>
    <li><a href="index.html">イントロダクション</a></li>
    <li><a href="getting-started.html">スタートガイド</a></li>
    <li><a href="configuration.html"><span class="icon-chevron-right"></span>設定</a></li>
    <li><a href="sqlmap-xml.html"><span class="icon-chevron-right"></span>Mapper XML ファイル</a></li>
    <li class="active"><a>動的 SQL</a></li>
    <li><a href="java-api.html"><span class="icon-chevron-right"></span>Java API</a></li>
    <li><a href="statement-builders.html"><span class="icon-chevron-right"></span>ステートメントビルダー</a></li>
    <li><a href="logging.html">ロギング</a></li>
   <li class="nav-header">プロジェクト文書</li>
    <li><a href="project-info.html"><span class="icon-chevron-right"></span>プロジェクト情報</a></li>
    <li><a href="project-reports.html"><span class="icon-chevron-right"></span>プロジェクトレポート</a></li>
  </ul>
          </nav>
          <div class="well sidebar-nav">
            <div id="poweredBy">
              <div class="clear"></div>
              <div class="clear"></div>
              <div class="clear"></div>
<a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
            </div>
          </div>
        </header>
        <main id="bodyColumn" class="span10">


  
  <section>
<h1>&#x52d5;&#x7684; SQL</h1>
  
<p>Mybatis &#x306e;&#x5f37;&#x529b;&#x306a;&#x6a5f;&#x80fd;&#x306e;&#x3072;&#x3068;&#x3064;&#x306b;&#x3001;&#x52d5;&#x7684; SQL &#x304c;&#x3042;&#x308a;&#x307e;&#x3059;&#x3002;&#x3082;&#x3057;&#x3001;JDBC &#x3084;&#x985e;&#x4f3c;&#x306e;&#x30d5;&#x30ec;&#x30fc;&#x30e0;&#x30ef;&#x30fc;&#x30af;&#x3092;&#x4f7f;&#x3063;&#x305f;&#x3053;&#x3068;&#x304c;&#x3042;&#x308b;&#x306a;&#x3089;&#x3001;&#x6761;&#x4ef6;&#x306b;&#x5408;&#x3046;&#x3088;&#x3046;&#x306b;&#x6587;&#x5b57;&#x5217;&#x3092;&#x3064;&#x306a;&#x304e;&#x5408;&#x308f;&#x305b;&#x3066;&#x3001;&#x30b9;&#x30da;&#x30fc;&#x30b9;&#x3092;&#x5fd8;&#x308c;&#x305f;&#x308a;&#x3001;&#x5217;&#x306e;&#x30ea;&#x30b9;&#x30c8;&#x306e;&#x672b;&#x5c3e;&#x306e;&#x30ab;&#x30f3;&#x30de;&#x3092;&#x524a;&#x9664;&#x3059;&#x308b;&#x306e;&#x3092;&#x5fd8;&#x308c;&#x306a;&#x3044;&#x3088;&#x3046;&#x306b;&#x6ce8;&#x610f;&#x3057;&#x306a;&#x304c;&#x3089; SQL &#x3092;&#x69cb;&#x7bc9;&#x3059;&#x308b;&#x306e;&#x304c;&#x5982;&#x4f55;&#x306b;&#x5927;&#x5909;&#x304b;&#x5206;&#x304b;&#x308b;&#x3068;&#x601d;&#x3044;&#x307e;&#x3059;&#x3002;&#x52d5;&#x7684;&#x306b; SQL &#x3092;&#x69cb;&#x7bc9;&#x3059;&#x308b;&#x306e;&#x306f;&#x5927;&#x5909;&#x306a;&#x82e6;&#x75db;&#x3092;&#x4f34;&#x3046;&#x5834;&#x5408;&#x304c;&#x3042;&#x308a;&#x307e;&#x3059;&#x3002;
</p>
  
<p>&#x52d5;&#x7684; SQL &#x306e;&#x69cb;&#x7bc9;&#x304c;&#x697d;&#x3057;&#x304f;&#x306a;&#x308b;&#x3053;&#x3068;&#x306f;&#x306a;&#x3044;&#x3067;&#x3057;&#x3087;&#x3046;&#x304c;&#x3001;MyBatis &#x304c;&#x63d0;&#x4f9b;&#x3059;&#x308b;&#x5f37;&#x529b;&#x306a;&#x52d5;&#x7684; SQL &#x8a00;&#x8a9e;&#x3092;&#x4f7f;&#x3048;&#x3070;&#x304b;&#x306a;&#x308a;&#x6539;&#x5584;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;
 </p>
  
<p>JSTL &#x306a;&#x3069;&#x306e; XML &#x30d9;&#x30fc;&#x30b9;&#x306e;&#x30c6;&#x30ad;&#x30b9;&#x30c8;&#x30d7;&#x30ed;&#x30bb;&#x30c3;&#x30b5;&#x3092;&#x4f7f;&#x3063;&#x305f;&#x3053;&#x3068;&#x304c;&#x3042;&#x308b;&#x306a;&#x3089;&#x3001;MyBatis &#x306e;&#x52d5;&#x7684; SQL &#x306e;&#x8981;&#x7d20;&#x306f;&#x99b4;&#x67d3;&#x307f;&#x3084;&#x3059;&#x3044;&#x3082;&#x306e;&#x3060;&#x3068;&#x601d;&#x3044;&#x307e;&#x3059;&#x3002;&#x4ee5;&#x524d;&#x306e;&#x30d0;&#x30fc;&#x30b8;&#x30e7;&#x30f3;&#x306e; MyBatis &#x3067;&#x306f;&#x7406;&#x89e3;&#x3057;&#x3066;&#x304a;&#x304b;&#x306a;&#x304f;&#x3066;&#x306f;&#x306a;&#x3089;&#x306a;&#x3044;&#x8981;&#x7d20;&#x304c;&#x6570;&#x591a;&#x304f;&#x3042;&#x308a;&#x307e;&#x3057;&#x305f;&#x304c;&#x3001;MyBatis 3 &#x3067;&#x306f;&#x6539;&#x826f;&#x306e;&#x7d50;&#x679c;&#x3001;&#x8981;&#x7d20;&#x306e;&#x6570;&#x306f;&#x534a;&#x5206;&#x4ee5;&#x4e0b;&#x306b;&#x306a;&#x3063;&#x3066;&#x3044;&#x307e;&#x3059;&#x3002;&#x8981;&#x7d20;&#x306e;&#x6570;&#x3092;&#x6e1b;&#x3089;&#x3059;&#x305f;&#x3081;&#x3001;MyBatis &#x3067;&#x306f; OGNL &#x30d9;&#x30fc;&#x30b9;&#x306e;&#x5f0f;&#xff08;expression&#xff09;&#x3092;&#x63a1;&#x7528;&#x3057;&#x3066;&#x3044;&#x307e;&#x3059;&#x3002;
  </p>
  
<ul>
    
<li>if</li>
    
<li>choose (when, otherwise)</li>
    
<li>trim (where, set)</li>
    
<li>foreach</li>
  </ul>
  <a id="if"></a><section id="if">
<h2>if</h2>
  
<p>&#x52d5;&#x7684; SQL &#x3067;&#x6700;&#x3082;&#x826f;&#x304f;&#x884c;&#x3046;&#x306e;&#x304c;&#x3001;&#x6b21;&#x306e;&#x3088;&#x3046;&#x306b;&#x6761;&#x4ef6;&#x306b;&#x5fdc;&#x3058;&#x3066; where &#x53e5;&#x306b;&#x691c;&#x7d22;&#x6761;&#x4ef6;&#x3092;&#x8ffd;&#x52a0;&#x3059;&#x308b;&#x51e6;&#x7406;&#x3067;&#x3057;&#x3087;&#x3046;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;select id=&quot;findActiveBlogWithTitleLike&quot;
     resultType=&quot;Blog&quot;&gt;
  SELECT * FROM BLOG
  WHERE state = &#x2018;ACTIVE&#x2019;
  &lt;if test=&quot;title != null&quot;&gt;
    AND title like #{title}
  &lt;/if&gt;
&lt;/select&gt;</pre></div>
  
<p>&#x3053;&#x306e;&#x30b9;&#x30c6;&#x30fc;&#x30c8;&#x30e1;&#x30f3;&#x30c8;&#x306b;&#x3088;&#x3063;&#x3066;&#x300c;&#x4efb;&#x610f;&#x306e;&#x691c;&#x7d22;&#x9805;&#x76ee;&#x300d;&#x3092;&#x5b9f;&#x73fe;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;title &#x3092;&#x6307;&#x5b9a;&#x3057;&#x306a;&#x3051;&#x308c;&#x3070;&#x5168;&#x3066;&#x306e; ACTIVE &#x306a; Blog &#x304c;&#x8fd4;&#x3055;&#x308c;&#x307e;&#x3059;&#x304c;&#x3001;title &#x3092;&#x6307;&#x5b9a;&#x3057;&#x305f;&#x5834;&#x5408;&#x306f;&#x6307;&#x5b9a;&#x3057;&#x305f;&#x30bf;&#x30a4;&#x30c8;&#x30eb;&#x3092;&#x6301;&#x3063;&#x305f; Blog &#x304c;&#x8fd4;&#x3055;&#x308c;&#x307e;&#x3059;&#xff08;&#x3053;&#x306e;&#x30b9;&#x30c6;&#x30fc;&#x30c8;&#x30e1;&#x30f3;&#x30c8;&#x3067;&#x306f; like &#x6f14;&#x7b97;&#x5b50;&#x3092;&#x4f7f;&#x3063;&#x3066;&#x3044;&#x308b;&#x306e;&#x3067;&#x3001;&#x6e21;&#x3055;&#x308c;&#x305f; title &#x306b;&#x30ef;&#x30a4;&#x30eb;&#x30c9;&#x30ab;&#x30fc;&#x30c9;&#x3092;&#x4f7f;&#x3046;&#x3053;&#x3068;&#x3082;&#x3067;&#x304d;&#x307e;&#x3059;&#xff09;&#x3002;</p>
  
<p>
    &#x30bf;&#x30a4;&#x30c8;&#x30eb;&#x3068;&#x8457;&#x8005;&#x306e;&#x4e21;&#x65b9;&#x3092;&#x4efb;&#x610f;&#x306e;&#x6761;&#x4ef6;&#x3068;&#x3057;&#x305f;&#x3044;&#x5834;&#x5408;&#x306f;&#x3069;&#x3046;&#x3059;&#x308c;&#x3070;&#x826f;&#x3044;&#x306e;&#x3067;&#x3057;&#x3087;&#x3046;&#x304b;&#x3002;<br />
    &#x30b9;&#x30c6;&#x30fc;&#x30c8;&#x30e1;&#x30f3;&#x30c8;&#x540d;&#x3092;&#x5206;&#x304b;&#x308a;&#x3084;&#x3059;&#x3044;&#x3082;&#x306e;&#x306b;&#x5909;&#x66f4;&#x3057;&#x305f;&#x3089;&#x3001;&#x3042;&#x3068;&#x306f;&#x6761;&#x4ef6;&#x3092;&#x3082;&#x3046;&#x4e00;&#x3064;&#x8ffd;&#x52a0;&#x3059;&#x308b;&#x3060;&#x3051;&#x3067;&#x3059;&#x3002;
  </p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;select id=&quot;findActiveBlogLike&quot;
     resultType=&quot;Blog&quot;&gt;
  SELECT * FROM BLOG WHERE state = &#x2018;ACTIVE&#x2019;
  &lt;if test=&quot;title != null&quot;&gt;
    AND title like #{title}
  &lt;/if&gt;
  &lt;if test=&quot;author != null and author.name != null&quot;&gt;
    AND author_name like #{author.name}
  &lt;/if&gt;
&lt;/select&gt;</pre></div>
  </section>
  <a id="chooseWhenOtherwise"></a><section id="chooseWhenOtherwise">
<h2>choose, when, otherwise</h2>
  
<p>&#x5168;&#x3066;&#x306e;&#x6761;&#x4ef6;&#x3092;&#x9069;&#x7528;&#x3059;&#x308b;&#x4ee3;&#x308f;&#x308a;&#x306b;&#x3001;&#x591a;&#x304f;&#x306e;&#x9078;&#x629e;&#x80a2;&#x306e;&#x4e2d;&#x304b;&#x3089;&#x4e00;&#x3064;&#x3092;&#x9078;&#x3093;&#x3067;&#x9069;&#x7528;&#x3057;&#x305f;&#x3044;&#x3068;&#x3044;&#x3046;&#x5834;&#x5408;&#x304c;&#x3042;&#x308a;&#x307e;&#x3059;&#x3002;</p>
  
<p>&#x5f15;&#x304d;&#x7d9a;&#x304d;&#x4e0a;&#x306e;&#x4f8b;&#x3092;&#x4f7f;&#x3063;&#x3066;&#x3001;&#x30bf;&#x30a4;&#x30c8;&#x30eb;&#x304c;&#x6307;&#x5b9a;&#x3055;&#x308c;&#x305f;&#x3089;&#x30bf;&#x30a4;&#x30c8;&#x30eb;&#x306e;&#x307f;&#x3092;&#x6761;&#x4ef6;&#x3068;&#x3057;&#x3066;&#x691c;&#x7d22;&#x3057;&#x3001;&#x8457;&#x8005;&#x304c;&#x6307;&#x5b9a;&#x3055;&#x308c;&#x305f;&#x3089;&#x8457;&#x8005;&#x306e;&#x307f;&#x3092;&#x6761;&#x4ef6;&#x3068;&#x3057;&#x3066;&#x691c;&#x7d22;&#x3059;&#x308b;&#x3088;&#x3046;&#x306b;&#x3057;&#x3066;&#x307f;&#x307e;&#x3057;&#x3087;&#x3046;&#x3002;&#x3069;&#x3061;&#x3089;&#x3082;&#x6307;&#x5b9a;&#x3055;&#x308c;&#x306a;&#x304b;&#x3063;&#x305f;&#x5834;&#x5408;&#x306f;&#x6ce8;&#x76ee;&#x306e;&#x30d6;&#x30ed;&#x30b0;&#x306e;&#x307f;&#x3092;&#x8fd4;&#x3059;&#x3088;&#x3046;&#x306b;&#x3057;&#x3066;&#x307f;&#x307e;&#x3057;&#x3087;&#x3046;&#xff08;&#x30e9;&#x30f3;&#x30c0;&#x30e0;&#x306b;&#x9078;&#x3070;&#x308c;&#x305f;&#x7121;&#x610f;&#x5473;&#x306a;&#x30ea;&#x30b9;&#x30c8;&#x3067;&#x306f;&#x306a;&#x304f;&#x3001;&#x7ba1;&#x7406;&#x8005;&#x304c;&#x6226;&#x7565;&#x7684;&#x306b;&#x9078;&#x3093;&#x3060;&#x30ea;&#x30b9;&#x30c8;&#x3092;&#x8fd4;&#x3057;&#x305f;&#x3044;&#x3068;&#x3044;&#x3046;&#x8981;&#x4ef6;&#x304c;&#x3042;&#x308b;&#x306e;&#x3067;&#x3057;&#x3087;&#x3046;&#xff09;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;select id=&quot;findActiveBlogLike&quot;
     resultType=&quot;Blog&quot;&gt;
  SELECT * FROM BLOG WHERE state = &#x2018;ACTIVE&#x2019;
  &lt;choose&gt;
    &lt;when test=&quot;title != null&quot;&gt;
      AND title like #{title}
    &lt;/when&gt;
    &lt;when test=&quot;author != null and author.name != null&quot;&gt;
      AND author_name like #{author.name}
    &lt;/when&gt;
    &lt;otherwise&gt;
      AND featured = 1
    &lt;/otherwise&gt;
  &lt;/choose&gt;
&lt;/select&gt;</pre></div>
  </section>
  <a id="trimWhereSet"></a><section id="trimWhereSet">
<h2>trim, where, set</h2>
  
<p>&#x3053;&#x3053;&#x307e;&#x3067;&#x306e;&#x4f8b;&#x984c;&#x306f;&#x52d5;&#x7684; SQL &#x306e;&#x5384;&#x4ecb;&#x306a;&#x554f;&#x984c;&#x70b9;&#x3092;&#x90fd;&#x5408;&#x3088;&#x304f;&#x907f;&#x3051;&#x3066;&#x3044;&#x307e;&#x3057;&#x305f;&#x3002;&#x3082;&#x3046;&#x4e00;&#x5ea6; if &#x306e;&#x4f8b;&#x306b;&#x623b;&#x3063;&#x3066;&#x3001;&#x4eca;&#x5ea6;&#x306f; &quot;ACTIVE = 1&quot; &#x3082;&#x52d5;&#x7684;&#x306a;&#x6761;&#x4ef6;&#x306b;&#x5909;&#x66f4;&#x3057;&#x3066;&#x307f;&#x307e;&#x3057;&#x3087;&#x3046;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;select id=&quot;findActiveBlogLike&quot;
     resultType=&quot;Blog&quot;&gt;
  SELECT * FROM BLOG
  WHERE
  &lt;if test=&quot;state != null&quot;&gt;
    state = #{state}
  &lt;/if&gt;
  &lt;if test=&quot;title != null&quot;&gt;
    AND title like #{title}
  &lt;/if&gt;
  &lt;if test=&quot;author != null and author.name != null&quot;&gt;
    AND author_name like #{author.name}
  &lt;/if&gt;
&lt;/select&gt;</pre></div>
  
<p>&#x3069;&#x306e;&#x6761;&#x4ef6;&#x306b;&#x3082;&#x4e00;&#x81f4;&#x3057;&#x306a;&#x3044;&#x5834;&#x5408;&#x306f;&#x3069;&#x3046;&#x306a;&#x308b;&#x306e;&#x3067;&#x3057;&#x3087;&#x3046;&#x304b;&#xff1f;&#x305d;&#x306e;&#x5834;&#x5408;&#x306f;&#x6b21;&#x306e;&#x3088;&#x3046;&#x306a; SQL &#x304c;&#x5b9f;&#x884c;&#x3055;&#x308c;&#x308b;&#x3053;&#x3068;&#x306b;&#x306a;&#x308a;&#x307e;&#x3059;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">SELECT * FROM BLOG
WHERE</pre></div>
  
<p>&#x3053;&#x306e; SQL &#x306f;&#x69cb;&#x6587;&#x30a8;&#x30e9;&#x30fc;&#x3067;&#x5931;&#x6557;&#x3059;&#x308b;&#x3067;&#x3057;&#x3087;&#x3046;&#x3002;&#x3082;&#x3057;&#xff12;&#x756a;&#x76ee;&#x306e;&#x6761;&#x4ef6;&#x3060;&#x3051;&#x304c;&#x4e00;&#x81f4;&#x3057;&#x305f;&#x3089;&#x3069;&#x3046;&#x306a;&#x308b;&#x306e;&#x3067;&#x3057;&#x3087;&#x3046;&#x304b;&#xff1f;&#x4eca;&#x5ea6;&#x306f;&#x6b21;&#x306e; SQL &#x306b;&#x306a;&#x308a;&#x307e;&#x3059;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">SELECT * FROM BLOG
WHERE
AND title like &#x2018;someTitle&#x2019;</pre></div>
  
<p>&#x3053;&#x308c;&#x307e;&#x305f;&#x69cb;&#x6587;&#x30a8;&#x30e9;&#x30fc;&#x3067;&#x5931;&#x6557;&#x3059;&#x308b;&#x3067;&#x3057;&#x3087;&#x3046;&#x3002;&#x52d5;&#x7684; SQL &#x306e;&#x554f;&#x984c;&#x306f;&#x5358;&#x306a;&#x308b;&#x6761;&#x4ef6;&#x5206;&#x5c90;&#x3060;&#x3051;&#x3067;&#x89e3;&#x6c7a;&#x3067;&#x304d;&#x308b;&#x3082;&#x306e;&#x3067;&#x306f;&#x3042;&#x308a;&#x307e;&#x305b;&#x3093;&#x3002;&#x81ea;&#x5206;&#x3067;&#x66f8;&#x3044;&#x305f;&#x3053;&#x3068;&#x304c;&#x3042;&#x308b;&#x65b9;&#x306a;&#x3089;&#x3001;&#x3082;&#x3046;&#x4e8c;&#x5ea6;&#x3068;&#x66f8;&#x304d;&#x305f;&#x304f;&#x306a;&#x3044;&#x3068;&#x601d;&#x3046;&#x306f;&#x305a;&#x3067;&#x3059;&#x3002;</p>
  
<p>MyBatis &#x306f;&#x7d04; 90% &#x306e;&#x30b1;&#x30fc;&#x30b9;&#x3092;&#x3046;&#x307e;&#x304f;&#x51e6;&#x7406;&#x3067;&#x304d;&#x308b;&#x7c21;&#x5358;&#x306a;&#x89e3;&#x6c7a;&#x7b56;&#x3092;&#x63d0;&#x4f9b;&#x3057;&#x307e;&#x3059;&#x3002;&#x6b8b;&#x308a;&#x306e; 10% &#x306b;&#x3064;&#x3044;&#x3066;&#x3082;&#x3001;&#x30ab;&#x30b9;&#x30bf;&#x30de;&#x30a4;&#x30ba;&#x3059;&#x308b;&#x3053;&#x3068;&#x3067;&#x51e6;&#x7406;&#x3067;&#x304d;&#x308b;&#x3088;&#x3046;&#x306b;&#x306a;&#x308a;&#x307e;&#x3059;&#x3002;&#x4e0a;&#x8a18;&#x306e;&#x4f8b;&#x306f;&#x3001;&#x4e00;&#x7b87;&#x6240;&#x4fee;&#x6b63;&#x3059;&#x308b;&#x3060;&#x3051;&#x3067;&#x671f;&#x5f85;&#x901a;&#x308a;&#x306b;&#x52d5;&#x4f5c;&#x3059;&#x308b;&#x3088;&#x3046;&#x306b;&#x306a;&#x308a;&#x307e;&#x3059;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;select id=&quot;findActiveBlogLike&quot;
     resultType=&quot;Blog&quot;&gt;
  SELECT * FROM BLOG
  &lt;where&gt;
    &lt;if test=&quot;state != null&quot;&gt;
         state = #{state}
    &lt;/if&gt;
    &lt;if test=&quot;title != null&quot;&gt;
        AND title like #{title}
    &lt;/if&gt;
    &lt;if test=&quot;author != null and author.name != null&quot;&gt;
        AND author_name like #{author.name}
    &lt;/if&gt;
  &lt;/where&gt;
&lt;/select&gt;</pre></div>
  
<p><em>where</em> &#x8981;&#x7d20;&#x306f;&#x3001;&#x5185;&#x5305;&#x3059;&#x308b;&#x30bf;&#x30b0;&#x306e;&#x3069;&#x308c;&#x304b;&#x304c;&#x7d50;&#x679c;&#x3092;&#x8fd4;&#x3059;&#x3068;&#x304d;&#x3060;&#x3051; &quot;WHERE&quot; &#x3092;&#x633f;&#x5165;&#x3057;&#x307e;&#x3059;&#x3002;&#x66f4;&#x306b;&#x3001;&#x5185;&#x5305;&#x3059;&#x308b;&#x30bf;&#x30b0;&#x304b;&#x3089;&#x8fd4;&#x3055;&#x308c;&#x305f;&#x7d50;&#x679c;&#x304c; &quot;AND&quot; &#x307e;&#x305f;&#x306f; &quot;OR&quot; &#x3067;&#x59cb;&#x307e;&#x3063;&#x3066;&#x3044;&#x305f;&#x5834;&#x5408;&#x306f;&#x3053;&#x308c;&#x3092;&#x524a;&#x9664;&#x3057;&#x307e;&#x3059;&#x3002;</p>
  
<p><em>where</em> &#x8981;&#x7d20;&#x306e;&#x52d5;&#x4f5c;&#x304c;&#x671f;&#x5f85;&#x3068;&#x7570;&#x306a;&#x308b;&#x5834;&#x5408;&#x306f;&#x3001;trim &#x8981;&#x7d20;&#x3092;&#x5b9a;&#x7fa9;&#x3059;&#x308b;&#x3053;&#x3068;&#x3067;&#x51e6;&#x7406;&#x5185;&#x5bb9;&#x3092;&#x30ab;&#x30b9;&#x30bf;&#x30de;&#x30a4;&#x30ba;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;trim prefix=&quot;WHERE&quot; prefixOverrides=&quot;AND |OR &quot;&gt;
  ...
&lt;/trim&gt;</pre></div>
  
<p><em>prefixOverrides</em> &#x5c5e;&#x6027;&#x306b;&#x306f;&#x30d1;&#x30a4;&#x30d7;&#x3067;&#x533a;&#x5207;&#x3089;&#x308c;&#x305f;&#x30aa;&#x30fc;&#x30d0;&#x30fc;&#x30e9;&#x30a4;&#x30c9;&#x5bfe;&#x8c61;&#x306e;&#x6587;&#x5b57;&#x5217;&#x3092;&#x6307;&#x5b9a;&#x3057;&#x307e;&#x3059;&#x3002;&#x3053;&#x3053;&#x3067;&#x306f;&#x30b9;&#x30da;&#x30fc;&#x30b9;&#x306b;&#x3082;&#x610f;&#x5473;&#x304c;&#x3042;&#x308a;&#x307e;&#x3059;&#x3002;trim &#x8981;&#x7d20;&#x306e; <em>prefixOverrides</em> &#x5c5e;&#x6027;&#x306e;&#x30ea;&#x30b9;&#x30c8;&#x306b;&#x542b;&#x307e;&#x308c;&#x308b;&#x6587;&#x5b57;&#x5217;&#x304c;&#x5148;&#x982d;&#x306b;&#x3042;&#x3063;&#x305f;&#x5834;&#x5408;&#x306f;&#x524a;&#x9664;&#x3055;&#x308c;&#x3001;<em>prefix</em> &#x5c5e;&#x6027;&#x3067;&#x6307;&#x5b9a;&#x3055;&#x308c;&#x305f;&#x6587;&#x5b57;&#x5217;&#x306f;&#x7d50;&#x679c;&#x304c;&#x7a7a;&#x3067;&#x306a;&#x3044;&#x5834;&#x5408;&#x5148;&#x982d;&#x306b;&#x633f;&#x5165;&#x3055;&#x308c;&#x307e;&#x3059;&#x3002;</p>
  
<p>&#x52d5;&#x7684;&#x306a; update &#x30b9;&#x30c6;&#x30fc;&#x30c8;&#x30e1;&#x30f3;&#x30c8;&#x306e;&#x305f;&#x3081;&#x306b;&#x540c;&#x3058;&#x3088;&#x3046;&#x306a;&#x8981;&#x7d20; <em>set</em> &#x304c;&#x7528;&#x610f;&#x3055;&#x308c;&#x3066;&#x3044;&#x307e;&#x3059;&#x3002;<em>set</em> &#x8981;&#x7d20;&#x3092;&#x4f7f;&#x3046;&#x3068;&#x3001;&#x30a2;&#x30c3;&#x30d7;&#x30c7;&#x30fc;&#x30c8;&#x5bfe;&#x8c61;&#x306e;&#x5217;&#x3092;&#x52d5;&#x7684;&#x306b;&#x8ffd;&#x52a0;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;&#x4f8b;&#xff1a;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;update id=&quot;updateAuthorIfNecessary&quot;&gt;
  update Author
    &lt;set&gt;
      &lt;if test=&quot;username != null&quot;&gt;username=#{username},&lt;/if&gt;
      &lt;if test=&quot;password != null&quot;&gt;password=#{password},&lt;/if&gt;
      &lt;if test=&quot;email != null&quot;&gt;email=#{email},&lt;/if&gt;
      &lt;if test=&quot;bio != null&quot;&gt;bio=#{bio}&lt;/if&gt;
    &lt;/set&gt;
  where id=#{id}
&lt;/update&gt;</pre></div>
  
<p><em>set</em> &#x8981;&#x7d20;&#x306f;&#x3001;&#x52d5;&#x7684;&#x306b; SET &#x30ad;&#x30fc;&#x30ef;&#x30fc;&#x30c9;&#x3092;&#x4ed8;&#x52a0;&#x3057;&#x3001;&#x4f59;&#x5206;&#x306a;&#x672b;&#x5c3e;&#x306e;&#x30ab;&#x30f3;&#x30de;&#x3092;&#x524a;&#x9664;&#x3057;&#x307e;&#x3059;&#x3002;</p>
  
<p>&#x3042;&#x308b;&#x3044;&#x306f;&#x3001;<em>trim</em>&#x3068;&#x3044;&#x3046;&#x8981;&#x7d20;&#x3092;&#x4f7f;&#x3063;&#x3066;&#x3082;&#x540c;&#x3058;&#x52b9;&#x679c;&#x304c;&#x5f97;&#x3089;&#x308c;&#x307e;&#x3059;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;trim prefix=&quot;SET&quot; suffixOverrides=&quot;,&quot;&gt;
  ...
&lt;/trim&gt;</pre></div>
  
<p>prefix &#x3092;&#x8ffd;&#x52a0;&#x3057;&#x3066;&#x3044;&#x308b;&#x70b9;&#x306f;&#x524d;&#x306e;&#x4f8b;&#x3068;&#x540c;&#x3058;&#x3067;&#x3059;&#x304c;&#x3001;&#x4eca;&#x56de;&#x306f; suffix &#x3092;&#x30aa;&#x30fc;&#x30d0;&#x30fc;&#x30e9;&#x30a4;&#x30c9;&#x3057;&#x3066;&#x3044;&#x308b;&#x70b9;&#x306b;&#x6ce8;&#x610f;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044;&#x3002;</p>
  </section>
  <section>
<h2>foreach</h2>
  
<p>&#x52d5;&#x7684; SQL &#x3067;&#x826f;&#x304f;&#x3042;&#x308b;&#x3082;&#x3046;&#x4e00;&#x3064;&#x306e;&#x8981;&#x4ef6;&#x306f;&#x3001;&#x30b3;&#x30ec;&#x30af;&#x30b7;&#x30e7;&#x30f3;&#x306e;&#x8981;&#x7d20;&#x3092;&#x30a4;&#x30c6;&#x30ec;&#x30fc;&#x30b7;&#x30e7;&#x30f3;&#x51e6;&#x7406;&#x3057;&#x305f;&#x3044;&#x3068;&#x3044;&#x3046;&#x3082;&#x306e;&#x3067;&#x3059;&#x3002;&#x591a;&#x304f;&#x306e;&#x5834;&#x5408;&#x3001;IN &#x6f14;&#x7b97;&#x5b50;&#x3092;&#x4f7f;&#x3063;&#x305f;&#x6761;&#x4ef6;&#x3092;&#x69cb;&#x7bc9;&#x3059;&#x308b;&#x306e;&#x304c;&#x76ee;&#x7684;&#x3067;&#x3059;&#x3002;&#x4f8b;&#xff1a;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;select id=&quot;selectPostIn&quot; resultType=&quot;domain.blog.Post&quot;&gt;
  SELECT *
  FROM POST P
  &lt;where&gt;
    &lt;foreach item=&quot;item&quot; index=&quot;index&quot; collection=&quot;list&quot;
        open=&quot;ID in (&quot; separator=&quot;,&quot; close=&quot;)&quot; nullable=&quot;true&quot;&gt;
          #{item}
    &lt;/foreach&gt;
  &lt;/where&gt;
&lt;/select&gt;</pre></div>
  
<p><em>foreach</em> &#x8981;&#x7d20;&#x306f;&#x975e;&#x5e38;&#x306b;&#x5f37;&#x529b;&#x3067;&#x3001;&#x30a4;&#x30c6;&#x30ec;&#x30fc;&#x30b7;&#x30e7;&#x30f3;&#x51e6;&#x7406;&#x306e;&#x5bfe;&#x8c61;&#x3068;&#x306a;&#x308b;&#x30b3;&#x30ec;&#x30af;&#x30b7;&#x30e7;&#x30f3;&#x3092;&#x6307;&#x5b9a;&#x3059;&#x308b; collection &#x3068;&#x3001;&#x30eb;&#x30fc;&#x30d7;&#x5185;&#x3067;&#x8981;&#x7d20;&#x3092;&#x683c;&#x7d0d;&#x3059;&#x308b;&#x5909;&#x6570; item&#x3001;&#x30eb;&#x30fc;&#x30d7;&#x56de;&#x6570;&#x3092;&#x683c;&#x7d0d;&#x3059;&#x308b; index &#x5909;&#x6570;&#x3092;&#x5ba3;&#x8a00;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;&#x307e;&#x305f;&#x3001;&#x958b;&#x59cb;&#x30fb;&#x7d42;&#x4e86;&#x306e;&#x6587;&#x5b57;&#x5217;&#x3068;&#x30a4;&#x30c6;&#x30ec;&#x30fc;&#x30b7;&#x30e7;&#x30f3;&#x306e;&#x5408;&#x9593;&#x306b;&#x51fa;&#x529b;&#x3059;&#x308b;&#x533a;&#x5207;&#x308a;&#x6587;&#x5b57;&#x3092;&#x6307;&#x5b9a;&#x3059;&#x308b;&#x3053;&#x3068;&#x3082;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;foreach &#x30bf;&#x30b0;&#x306f;&#x8ce2;&#x3044;&#x306e;&#x3067;&#x3001;&#x4f59;&#x5206;&#x306a;&#x533a;&#x5207;&#x308a;&#x6587;&#x5b57;&#x3092;&#x51fa;&#x529b;&#x3059;&#x308b;&#x3053;&#x3068;&#x306f;&#x3042;&#x308a;&#x307e;&#x305b;&#x3093;&#x3002;</p>
  
<p><span class="label important">NOTE</span> collection &#x306b;&#x306f; Iterable &#x3092;&#x5b9f;&#x88c5;&#x3057;&#x305f;&#x30aa;&#x30d6;&#x30b8;&#x30a7;&#x30af;&#x30c8;&#xff08;List &#x3084; Set &#x306a;&#x3069;&#xff09;&#x306e;&#x4ed6;&#x306b; Map &#x3084; Array &#x3092;&#x6307;&#x5b9a;&#x3059;&#x308b;&#x3053;&#x3068;&#x3082;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;collection &#x306b; Iterable &#x307e;&#x305f;&#x306f; Array &#x3092;&#x6307;&#x5b9a;&#x3057;&#x305f;&#x5834;&#x5408;&#x3001; index &#x3067;&#x6307;&#x5b9a;&#x3057;&#x305f;&#x5909;&#x6570;&#x306b;&#x306f;&#x30a4;&#x30f3;&#x30c7;&#x30c3;&#x30af;&#x30b9;&#x306e;&#x6570;&#x5024;&#x3001; item &#x3067;&#x6307;&#x5b9a;&#x3057;&#x305f;&#x5909;&#x6570;&#x306b;&#x306f;&#x30b3;&#x30ec;&#x30af;&#x30b7;&#x30e7;&#x30f3;&#x3001;&#x914d;&#x5217;&#x306e;&#x8981;&#x7d20;&#x304c;&#x683c;&#x7d0d;&#x3055;&#x308c;&#x307e;&#x3059;&#x3002;Map &#x3042;&#x308b;&#x3044;&#x306f; Map.Entry &#x306e;&#x30b3;&#x30ec;&#x30af;&#x30b7;&#x30e7;&#x30f3;&#x3092;&#x6307;&#x5b9a;&#x3057;&#x305f;&#x5834;&#x5408;&#x306f; index &#x306b;&#x30de;&#x30c3;&#x30d7;&#x306e;&#x30ad;&#x30fc;&#x3001;item &#x306b;&#x30de;&#x30c3;&#x30d7;&#x306e;&#x5024;&#x304c;&#x683c;&#x7d0d;&#x3055;&#x308c;&#x307e;&#x3059;&#x3002;</p>
  
<p>XML &#x8a2d;&#x5b9a;&#x30d5;&#x30a1;&#x30a4;&#x30eb;&#x3068; XML Mapper &#x30d5;&#x30a1;&#x30a4;&#x30eb;&#x306b;&#x3064;&#x3044;&#x3066;&#x306e;&#x8aac;&#x660e;&#x306f;&#x3053;&#x3053;&#x307e;&#x3067;&#x306b;&#x306a;&#x308a;&#x307e;&#x3059;&#x3002;&#x6b21;&#x306e;&#x7ae0;&#x3067;&#x306f;&#x3001;Java API &#x306b;&#x3064;&#x3044;&#x3066;&#x8a73;&#x3057;&#x304f;&#x898b;&#x3066;&#x3044;&#x304d;&#x307e;&#x3059;&#x3002;</p>
  </section>
  <section>
<h2>script</h2>
  
<p>For using dynamic SQL in annotated mapper class, <em>script</em> element can be used. For example:</p>
  
<div class="verbatim source"><pre class="prettyprint">
    @Update({&quot;&lt;script&gt;&quot;,
      &quot;update Author&quot;,
      &quot;  &lt;set&gt;&quot;,
      &quot;    &lt;if test='username != null'&gt;username=#{username},&lt;/if&gt;&quot;,
      &quot;    &lt;if test='password != null'&gt;password=#{password},&lt;/if&gt;&quot;,
      &quot;    &lt;if test='email != null'&gt;email=#{email},&lt;/if&gt;&quot;,
      &quot;    &lt;if test='bio != null'&gt;bio=#{bio}&lt;/if&gt;&quot;,
      &quot;  &lt;/set&gt;&quot;,
      &quot;where id=#{id}&quot;,
      &quot;&lt;/script&gt;&quot;})
    void updateAuthorValues(Author author);</pre></div>
  </section>
  <section>
<h2>bind</h2>
  
<p><code>bind</code> &#x8981;&#x7d20;&#x3092;&#x4f7f;&#x3046;&#x3068;&#x3001;OGNL &#x5f0f;&#x306e;&#x7d50;&#x679c;&#x3092;&#x5909;&#x6570;&#x306b;&#x683c;&#x7d0d;&#x3057;&#x3001;&#x305d;&#x306e;&#x5909;&#x6570;&#x3092; SQL &#x6587;&#x4e2d;&#x3067;&#x4f7f;&#x7528;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">
&lt;select id=&quot;selectBlogsLike&quot; resultType=&quot;Blog&quot;&gt;
  &lt;bind name=&quot;pattern&quot; value=&quot;'%' + _parameter.getTitle() + '%'&quot; /&gt;
  SELECT * FROM BLOG
  WHERE title LIKE #{pattern}
&lt;/select&gt;</pre></div>
  </section>
  <section>
<h2>&#x8907;&#x6570;&#x30c7;&#x30fc;&#x30bf;&#x30d9;&#x30fc;&#x30b9;&#x306e;&#x30b5;&#x30dd;&#x30fc;&#x30c8;</h2>
  
<p>databaseIdProvider &#x304c;&#x8a2d;&#x5b9a;&#x3055;&#x308c;&#x3066;&#x3044;&#x308b;&#x5834;&#x5408;&#x3001;&#x6761;&#x4ef6;&#x5f0f;&#x3067; &quot;_databaseId&quot; &#x5909;&#x6570;&#x304c;&#x5229;&#x7528;&#x53ef;&#x80fd;&#x3068;&#x306a;&#x308a;&#x307e;&#x3059;&#x3002;&#x3053;&#x306e;&#x5909;&#x6570;&#x3092;&#x4f7f;&#x3046;&#x3068;&#x3001;&#x5b9f;&#x884c;&#x6642;&#x306e;&#x30c7;&#x30fc;&#x30bf;&#x30d9;&#x30fc;&#x30b9;&#x306b;&#x5fdc;&#x3058;&#x3066;&#x30b9;&#x30c6;&#x30fc;&#x30c8;&#x30e1;&#x30f3;&#x30c8;&#x3092;&#x4f7f;&#x3044;&#x5206;&#x3051;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;oracle &#x3068; db2 &#x3067;&#x7570;&#x306a;&#x308b; select &#x6587;&#x3092;&#x767a;&#x884c;&#x3059;&#x308b;&#x4f8b;&#x3092;&#x6b21;&#x306b;&#x6319;&#x3052;&#x3066;&#x304a;&#x304d;&#x307e;&#x3059;&#x3002;</p>
  
<div class="verbatim source"><pre class="prettyprint">&lt;insert id=&quot;insert&quot;&gt;
  &lt;selectKey keyProperty=&quot;id&quot; resultType=&quot;int&quot; order=&quot;BEFORE&quot;&gt;
    &lt;if test=&quot;_databaseId == 'oracle'&quot;&gt;
      select seq_users.nextval from dual
    &lt;/if&gt;
    &lt;if test=&quot;_databaseId == 'db2'&quot;&gt;
      select nextval for seq_users from sysibm.sysdummy1&quot;
    &lt;/if&gt;
  &lt;/selectKey&gt;
  insert into users values (#{id}, #{name})
&lt;/insert&gt;
</pre></div>
  </section>
  <section>
<h2>&#x30c0;&#x30a4;&#x30ca;&#x30df;&#x30c3;&#x30af; SQL &#x8a18;&#x8ff0;&#x8a00;&#x8a9e;</h2>
    
<p>&#x30d0;&#x30fc;&#x30b8;&#x30e7;&#x30f3; 3.2 &#x4ee5;&#x964d;&#x3001;&#x30c0;&#x30a4;&#x30ca;&#x30df;&#x30c3;&#x30af; SQL &#x306e;&#x8a18;&#x8ff0;&#x8a00;&#x8a9e;&#x304c; Pluggable &#x306b;&#x306a;&#x308a;&#x307e;&#x3057;&#x305f;&#x3002;&#x8a00;&#x8a9e;&#x30c9;&#x30e9;&#x30a4;&#x30d0;&#x30fc;&#x3092;&#x8a18;&#x8ff0;&#x3059;&#x308b;&#x3053;&#x3068;&#x3067;&#x3001;&#x4efb;&#x610f;&#x306e;&#x8a00;&#x8a9e;&#x3067;&#x30c0;&#x30a4;&#x30ca;&#x30df;&#x30c3;&#x30af; SQL &#x3092;&#x8a18;&#x8ff0;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;</p>
    
<p>&#x30ab;&#x30b9;&#x30bf;&#x30e0;&#x306e;&#x8a00;&#x8a9e;&#x30c9;&#x30e9;&#x30a4;&#x30d0;&#x30fc;&#x3092;&#x4f7f;&#x7528;&#x3059;&#x308b;&#x5834;&#x5408;&#x3001;&#x307e;&#x305a;&#x306f; LanguageDriver &#x30a4;&#x30f3;&#x30bf;&#x30fc;&#x30d5;&#x30a7;&#x30a4;&#x30b9;&#x3092;&#x5b9f;&#x88c5;&#x3057;&#x305f;&#x30af;&#x30e9;&#x30b9;&#x3092;&#x4f5c;&#x6210;&#x3057;&#x307e;&#x3059;&#x3002;</p>
    
<div class="verbatim source"><pre class="prettyprint">public interface LanguageDriver {
  ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);
  SqlSource createSqlSource(Configuration configuration, XNode script, Class&lt;?&gt; parameterType);
  SqlSource createSqlSource(Configuration configuration, String script, Class&lt;?&gt; parameterType);
}</pre></div>
    
<p>&#x4f5c;&#x6210;&#x3057;&#x305f;&#x8a00;&#x8a9e;&#x30c9;&#x30e9;&#x30a4;&#x30d0;&#x30fc;&#x3092;&#x30c7;&#x30d5;&#x30a9;&#x30eb;&#x30c8;&#x3068;&#x3057;&#x3066;&#x4f7f;&#x7528;&#x3059;&#x308b;&#x5834;&#x5408;&#x306f;&#x3001;mybatis-config.xml &#x306b;&#x6b21;&#x306e;&#x3088;&#x3046;&#x306a;&#x8a2d;&#x5b9a;&#x3092;&#x8ffd;&#x52a0;&#x3057;&#x307e;&#x3059;&#xff08;typeAlias &#x306e;&#x4f7f;&#x7528;&#x306f;&#x5fc5;&#x9808;&#x3067;&#x306f;&#x3042;&#x308a;&#x307e;&#x305b;&#x3093;&#xff09;&#x3002;</p>
    
<div class="verbatim source"><pre class="prettyprint">&lt;typeAliases&gt;
  &lt;typeAlias type=&quot;org.sample.MyLanguageDriver&quot; alias=&quot;myLanguage&quot;/&gt;
&lt;/typeAliases&gt;
&lt;settings&gt;
  &lt;setting name=&quot;defaultScriptingLanguage&quot; value=&quot;myLanguage&quot;/&gt;
&lt;/settings&gt;
</pre></div>
    
<p><code>lang</code> &#x5c5e;&#x6027;&#x3092;&#x6307;&#x5b9a;&#x3059;&#x308b;&#x3053;&#x3068;&#x3067;&#x3001;&#x7279;&#x5b9a;&#x306e;&#x30b9;&#x30c6;&#x30fc;&#x30c8;&#x30e1;&#x30f3;&#x30c8;&#x306e;&#x8a00;&#x8a9e;&#x30c9;&#x30e9;&#x30a4;&#x30d0;&#x30fc;&#x306e;&#x307f;&#x3092;&#x5909;&#x66f4;&#x3059;&#x308b;&#x3053;&#x3068;&#x3082;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;</p>
    
<div class="verbatim source"><pre class="prettyprint">&lt;select id=&quot;selectBlog&quot; lang=&quot;myLanguage&quot;&gt;
  SELECT * FROM BLOG
&lt;/select&gt;</pre></div>
    
<p>Mapper &#x30a4;&#x30f3;&#x30bf;&#x30fc;&#x30d5;&#x30a7;&#x30a4;&#x30b9;&#x3092;&#x4f7f;&#x3063;&#x3066;&#x3044;&#x308b;&#x5834;&#x5408;&#x306f; <code>@Lang</code> &#x30a2;&#x30ce;&#x30c6;&#x30fc;&#x30b7;&#x30e7;&#x30f3;&#x3092;&#x4f7f;&#x3044;&#x307e;&#x3059;&#x3002;</p>
    
<div class="verbatim source"><pre class="prettyprint">public interface Mapper {
  @Lang(MyLanguageDriver.class)
  @Select(&quot;SELECT * FROM BLOG&quot;)
  List&lt;Blog&gt; selectBlog();
}</pre></div>

    
<p><span class="label important">NOTE</span> Apache Velocity &#x3092;&#x4f7f;&#x3063;&#x3066;&#x30c0;&#x30a4;&#x30ca;&#x30df;&#x30c3;&#x30af; SQL &#x3092;&#x8a18;&#x8ff0;&#x3059;&#x308b;&#x3053;&#x3068;&#x304c;&#x3067;&#x304d;&#x307e;&#x3059;&#x3002;MyBatis-Velocity &#x30d7;&#x30ed;&#x30b8;&#x30a7;&#x30af;&#x30c8;&#x3092;&#x53c2;&#x7167;&#x3057;&#x3066;&#x304f;&#x3060;&#x3055;&#x3044;&#x3002;</p>

    
<p>&#x3053;&#x308c;&#x307e;&#x3067;&#x306e;&#x30bb;&#x30af;&#x30b7;&#x30e7;&#x30f3;&#x3067;&#x51fa;&#x3066;&#x304d;&#x305f; XML &#x30bf;&#x30b0;&#x306f;&#x3001;&#x5168;&#x3066;&#x30c7;&#x30d5;&#x30a9;&#x30eb;&#x30c8;&#x306e;&#x8a00;&#x8a9e;&#x30c9;&#x30e9;&#x30a4;&#x30d0;&#x30fc; <code>org.apache.ibatis.scripting.xmltags.XmlLanguageDriver</code> &#xff08;&#x30a8;&#x30a4;&#x30ea;&#x30a2;&#x30b9;&#x306f; <code>xml</code> &#xff09;&#x306b;&#x3088;&#x3063;&#x3066;&#x63d0;&#x4f9b;&#x3055;&#x308c;&#x3066;&#x3044;&#x308b;&#x3082;&#x306e;&#x3067;&#x3059;&#x3002;</p>

    </section>
    </section>
  

        </main>
      </div>
    </div>
    <hr/>
    <footer>
      <div class="container-fluid">
        <div class="row-fluid">
            <p>©      2009–2024
<a href="https://www.mybatis.org/">MyBatis.org</a>
</p>
        </div>
      </div>
    </footer>
<script>
  if(anchors) {
    anchors.add();
  }
</script>
  </body>
</html>
back to top