You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2017/08/25 18:20:07 UTC

svn commit: r1017291 [2/2] - in /websites/production/camel/content: book-in-one-page.html cache/main.pageCache mina.html mybatis.html

Modified: websites/production/camel/content/mybatis.html
==============================================================================
--- websites/production/camel/content/mybatis.html (original)
+++ websites/production/camel/content/mybatis.html Fri Aug 25 18:20:06 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: MyBatis
@@ -86,30 +75,17 @@
 	<tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="MyBatis-MyBatis">MyBatis</h2><p><strong>Available as of Camel 2.7</strong></p><p>The <strong>mybatis:</strong> component allows you to query, poll, insert, update and delete data in a relational database using <a shape="rect" class="external-link" href="http://mybatis.org/" rel="nofollow">MyBatis</a>.</p><p>Maven users will need to add the following dependency to their <code>pom.xml</code> for this component:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
+<div class="wiki-content maincontent"><h2 id="MyBatis-MyBatis">MyBatis</h2><p><strong>Available as of Camel 2.7</strong></p><p>The <strong>mybatis:</strong> component allows you to query, poll, insert, update and delete data in a relational database using <a shape="rect" class="external-link" href="http://mybatis.org/" rel="nofollow">MyBatis</a>.</p><p>Maven users will need to add the following dependency to their <code>pom.xml</code> for this component:</p><parameter ac:name="">xml</parameter><plain-text-body>&lt;dependency&gt;
     &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
     &lt;artifactId&gt;camel-mybatis&lt;/artifactId&gt;
     &lt;version&gt;x.x.x&lt;/version&gt;
     &lt;!-- use the same version as your Camel core version --&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div><h3 id="MyBatis-URIformat">URI format</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[mybatis:statementName[?options]
-]]></script>
-</div></div><p>Where <strong>statementName</strong> is the statement name in the MyBatis XML mapping file which maps to the query, insert, update or delete operation you wish to evaluate.</p><p>You can append query options to the URI in the following format, <code>?option=value&amp;option=value&amp;...</code></p><p>This component will by default load the MyBatis SqlMapConfig file from the root of the classpath with the expected name of <code>SqlMapConfig.xml</code>.<br clear="none"> If the file is located in another location, you will need to configure the <code>configurationUri</code> option on the <code>MyBatisComponent</code> component.</p><h3 id="MyBatis-Options">Options</h3><div class="confluenceTableSmall"><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default</p></th><th colsp
 an="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>consumer.onConsume</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Statements to run after consuming. Can be used, for example, to update rows after they have been consumed and processed in Camel. See sample later. Multiple statements can be separated with commas.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>consumer.useIterator</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <code>true</code> each row returned when polling will be processed individually. If <code>false</cod
 e> the entire <code>List</code> of data is set as the IN body.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>consumer.routeEmptyResultSet</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets whether empty result sets should be routed.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>statementType</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>StatementType</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Mandatory to specify for the producer to control which kind of operation to invoke. The enum values are: <code>SelectOne</code>, <code>SelectList</code>, <code>Insert</code>, <code>InsertList</code>, <code>Update</code>, <code>Update
 List</code>, <code>Delete</code>, and <code>DeleteList</code>. <strong>Notice:</strong> <code>InsertList</code> is available as of Camel 2.10, and <code>UpdateList</code>, <code>DeleteList</code> is available as of Camel 2.11.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>maxMessagesPerPoll</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>int</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>This option is intended to split results returned by the database pool into the batches and deliver them in multiple exchanges. This integer defines the maximum messages to deliver in single exchange. By default, no maximum is set. Can be used to set a limit of e.g. 1000 to avoid when starting up the server that there are thousands of files. Set a value of 0 or negative to disable it.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>
 <code>executorType</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> The executor type to be used while executing statements. The supported values are: simple, reuse, batch. By default, the value is not specified and is equal to what MyBatis uses, i.e. <strong>simple</strong>. <br clear="none" class="atl-forced-newline"> <strong>simple</strong> executor does nothing special. <br clear="none" class="atl-forced-newline"> <strong>reuse</strong> executor reuses prepared statements. <br clear="none" class="atl-forced-newline"> <strong>batch</strong> executor reuses statements and batches updates.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>outputHeader</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><code>String</code></td><td colspan="1" ro
 wspan="1" class="confluenceTd"><code>null</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.15:</strong><span style="color: rgb(0,0,0);">&#160;To store the result as a header instead of the message body. This allows to preserve the existing message body as-is.</span></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>inputHeader</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>String</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>null</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.15: &#160;</strong>"inputHeader" parameter to use a header value as input to the component instead of the body.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>transacted</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd"><stron
 g>Camel 2.16.2:</strong><span>&#160;</span><strong>SQL consumer only:</strong><span>Enables or disables transaction. If enabled then if processing an exchange failed then the consumer break out processing any further exchanges to cause a rollback eager</span></td></tr></tbody></table></div></div>
-
-
-<h3 id="MyBatis-MessageHeaders">Message Headers</h3><p>Camel will populate the result message, either IN or OUT with a header with the statement used:</p><div class="confluenceTableSmall"><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelMyBatisStatementName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The <strong>statementName</strong> used (for example: insertAccount).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelMyBatisResult</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Object</code></p></td><td colspan="1" rowspan="1" class="confl
 uenceTd"><p>The <strong>response</strong> returned from MtBatis in any of the operations. For instance an <code>INSERT</code> could return the auto-generated key, or number of rows etc.</p></td></tr></tbody></table></div></div>
-
-
-<h3 id="MyBatis-MessageBody">Message Body</h3><p>The response from MyBatis will only be set as the body if it's a <code>SELECT</code> statement. That means, for example, for <code>INSERT</code> statements Camel will not replace the body. This allows you to continue routing and keep the original body. The response from MyBatis is always stored in the header with the key <code>CamelMyBatisResult</code>.</p><h3 id="MyBatis-Samples">Samples</h3><p>For example if you wish to consume beans from a JMS queue and insert them into a database you could do the following:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;activemq:queue:newAccount&quot;).
-  to(&quot;mybatis:insertAccount?statementType=Insert&quot;);
-]]></script>
-</div></div><p>Notice we have to specify the <code>statementType</code>, as we need to instruct Camel which kind of operation to invoke.</p><p>Where <strong>insertAccount</strong> is the MyBatis ID in the SQL mapping file:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[  &lt;!-- Insert example, using the Account parameter class --&gt;
-  &lt;insert id=&quot;insertAccount&quot; parameterType=&quot;Account&quot;&gt;
+</plain-text-body><h3 id="MyBatis-URIformat">URI format</h3><plain-text-body>mybatis:statementName[?options]
+</plain-text-body><p>Where <strong>statementName</strong> is the statement name in the MyBatis XML mapping file which maps to the query, insert, update or delete operation you wish to evaluate.</p><p>You can append query options to the URI in the following format, <code>?option=value&amp;option=value&amp;...</code></p><p>This component will by default load the MyBatis SqlMapConfig file from the root of the classpath with the expected name of <code>SqlMapConfig.xml</code>.<br clear="none"> If the file is located in another location, you will need to configure the <code>configurationUri</code> option on the <code>MyBatisComponent</code> component.</p><h3 id="MyBatis-Options">Options</h3><parameter ac:name="class">confluenceTableSmall</parameter><rich-text-body><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" cl
 ass="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>consumer.onConsume</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Statements to run after consuming. Can be used, for example, to update rows after they have been consumed and processed in Camel. See sample later. Multiple statements can be separated with commas.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>consumer.useIterator</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <code>true</code> each row returned when polling will
  be processed individually. If <code>false</code> the entire <code>List</code> of data is set as the IN body.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>consumer.routeEmptyResultSet</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets whether empty result sets should be routed.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>statementType</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>StatementType</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Mandatory to specify for the producer to control which kind of operation to invoke. The enum values are: <code>SelectOne</code>, <code>SelectList</code>, <code>Insert</code>, <code>Inser
 tList</code>, <code>Update</code>, <code>UpdateList</code>, <code>Delete</code>, and <code>DeleteList</code>. <strong>Notice:</strong> <code>InsertList</code> is available as of Camel 2.10, and <code>UpdateList</code>, <code>DeleteList</code> is available as of Camel 2.11.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>maxMessagesPerPoll</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>int</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>This option is intended to split results returned by the database pool into the batches and deliver them in multiple exchanges. This integer defines the maximum messages to deliver in single exchange. By default, no maximum is set. Can be used to set a limit of e.g. 1000 to avoid when starting up the server that there are thousands of files. Set a value of 0 or negative to disable it.</p></td></tr><tr><td c
 olspan="1" rowspan="1" class="confluenceTd"><p><code>executorType</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> The executor type to be used while executing statements. The supported values are: simple, reuse, batch. By default, the value is not specified and is equal to what MyBatis uses, i.e. <strong>simple</strong>. <br clear="none" class="atl-forced-newline"> <strong>simple</strong> executor does nothing special. <br clear="none" class="atl-forced-newline"> <strong>reuse</strong> executor reuses prepared statements. <br clear="none" class="atl-forced-newline"> <strong>batch</strong> executor reuses statements and batches updates.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>outputHeader</code></p></td><td colspan="1" rowspan="1" class="confluenc
 eTd"><code>String</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>null</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.15:</strong><span style="color: rgb(0,0,0);">&#160;To store the result as a header instead of the message body. This allows to preserve the existing message body as-is.</span></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>inputHeader</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>String</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>null</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.15: &#160;</strong>"inputHeader" parameter to use a header value as input to the component instead of the body.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>transacted</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td cols
 pan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.16.2:</strong><span>&#160;</span><strong>SQL consumer only:</strong><span>Enables or disables transaction. If enabled then if processing an exchange failed then the consumer break out processing any further exchanges to cause a rollback eager</span></td></tr></tbody></table></div></rich-text-body><h3 id="MyBatis-MessageHeaders">Message Headers</h3><p>Camel will populate the result message, either IN or OUT with a header with the statement used:</p><parameter ac:name="class">confluenceTableSmall</parameter><rich-text-body><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelMyBatisStatementName</code></p></td><td colspan="1" rowspan="1" class="
 confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The <strong>statementName</strong> used (for example: insertAccount).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelMyBatisResult</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Object</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The <strong>response</strong> returned from MtBatis in any of the operations. For instance an <code>INSERT</code> could return the auto-generated key, or number of rows etc.</p></td></tr></tbody></table></div></rich-text-body><h3 id="MyBatis-MessageBody">Message Body</h3><p>The response from MyBatis will only be set as the body if it's a <code>SELECT</code> statement. That means, for example, for <code>INSERT</code> statements Camel will not replace the body. This allows you to continue routing and keep the original body. The response from MyBatis is always stored in the header with
  the key <code>CamelMyBatisResult</code>.</p><h3 id="MyBatis-Samples">Samples</h3><p>For example if you wish to consume beans from a JMS queue and insert them into a database you could do the following:</p><plain-text-body>from("activemq:queue:newAccount").
+  to("mybatis:insertAccount?statementType=Insert");
+</plain-text-body><p>Notice we have to specify the <code>statementType</code>, as we need to instruct Camel which kind of operation to invoke.</p><p>Where <strong>insertAccount</strong> is the MyBatis ID in the SQL mapping file:</p><parameter ac:name="">xml</parameter><plain-text-body>  &lt;!-- Insert example, using the Account parameter class --&gt;
+  &lt;insert id="insertAccount" parameterType="Account"&gt;
     insert into ACCOUNT (
       ACC_ID,
       ACC_FIRST_NAME,
@@ -120,153 +96,70 @@
       #{id}, #{firstName}, #{lastName}, #{emailAddress}
     )
   &lt;/insert&gt;
-]]></script>
-</div></div><h3 id="MyBatis-UsingStatementTypeforbettercontrolofMyBatis">Using StatementType for better control of MyBatis</h3><p>When routing to an MyBatis endpoint you will want more fine grained control so you can control whether the SQL statement to be executed is a <code>SELECT</code>, <code>UPDATE</code>, <code>DELETE</code> or <code>INSERT</code> etc. So for instance if we want to route to an MyBatis endpoint in which the IN body contains parameters to a <code>SELECT</code> statement we can do:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
-    .to(&quot;mybatis:selectAccountById?statementType=SelectOne&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div>In the code above we can invoke the MyBatis statement <code>selectAccountById</code> and the IN body should contain the account id we want to retrieve, such as an <code>Integer</code> type.<p>We can do the same for some of the other operations, such as <code>SelectList</code>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
-    .to(&quot;mybatis:selectAllAccounts?statementType=SelectList&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div>And the same for <code>UPDATE</code>, where we can send an <code>Account</code> object as the IN body to MyBatis:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
-    .to(&quot;mybatis:updateAccount?statementType=Update&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div><h4 id="MyBatis-UsingInsertListStatementType">Using InsertList StatementType</h4><p><strong>Available as of Camel 2.10</strong></p><p>MyBatis allows you to insert multiple rows using its for-each batch driver. To use this, you need to use the &lt;foreach&gt; in the mapper XML file. For example as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-&lt;!-- Batch Insert example, using the Account parameter class --&gt;
-&lt;insert id=&quot;batchInsertAccount&quot; parameterType=&quot;java.util.List&quot;&gt;
-    insert into ACCOUNT (
-    ACC_ID,
-    ACC_FIRST_NAME,
-    ACC_LAST_NAME,
-    ACC_EMAIL
-    )
-    values (
-    &lt;foreach item=&quot;Account&quot; collection=&quot;list&quot; open=&quot;&quot; close=&quot;&quot; separator=&quot;),(&quot;&gt;
-        #{Account.id}, #{Account.firstName}, #{Account.lastName}, #{Account.emailAddress}
-    &lt;/foreach&gt;
-    )
-&lt;/insert&gt;
-]]></script>
-</div></div>Then you can insert multiple rows, by sending a Camel message to the <code>mybatis</code> endpoint which uses the <code>InsertList</code> statement type, as shown below:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
-    .to(&quot;mybatis:batchInsertAccount?statementType=InsertList&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div><h4 id="MyBatis-UsingUpdateListStatementType">Using UpdateList StatementType</h4><p><strong>Available as of Camel 2.11</strong></p><p>MyBatis allows you to update multiple rows using its for-each batch driver. To use this, you need to use the &lt;foreach&gt; in the mapper XML file. For example as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;update id=&quot;batchUpdateAccount&quot; parameterType=&quot;java.util.Map&quot;&gt;
+</plain-text-body><h3 id="MyBatis-UsingStatementTypeforbettercontrolofMyBatis">Using StatementType for better control of MyBatis</h3><p>When routing to an MyBatis endpoint you will want more fine grained control so you can control whether the SQL statement to be executed is a <code>SELECT</code>, <code>UPDATE</code>, <code>DELETE</code> or <code>INSERT</code> etc. So for instance if we want to route to an MyBatis endpoint in which the IN body contains parameters to a <code>SELECT</code> statement we can do:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectOneTest.java}</plain-text-body>In the code above we can invoke the MyBatis statement <code>selectAccountById</code> and the IN body should contain the account id we want to retrieve, such as an <code>Integer</code> type.</p><p>We can do the same for some of the other operations, such as <code>SelectList</code>:<plain-text-body>{snippet:id
 =e1|lang=java|url=camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisSelectListTest.java}</plain-text-body>And the same for <code>UPDATE</code>, where we can send an <code>Account</code> object as the IN body to MyBatis:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisUpdateTest.java}</plain-text-body></p><h4 id="MyBatis-UsingInsertListStatementType">Using InsertList StatementType</h4><p><strong>Available as of Camel 2.10</strong></p><p>MyBatis allows you to insert multiple rows using its for-each batch driver. To use this, you need to use the &lt;foreach&gt; in the mapper XML file. For example as shown below:<plain-text-body>{snippet:id=insertList|lang=xml|url=camel/trunk/components/camel-mybatis/src/test/resources/org/apache/camel/component/mybatis/Account.xml}</plain-text-body>Then you can insert multiple rows, by sending a Camel message to the <code
 >mybatis</code> endpoint which uses the <code>InsertList</code> statement type, as shown below:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisInsertListTest.java}</plain-text-body></p><h4 id="MyBatis-UsingUpdateListStatementType">Using UpdateList StatementType</h4><p><strong>Available as of Camel 2.11</strong></p><p>MyBatis allows you to update multiple rows using its for-each batch driver. To use this, you need to use the &lt;foreach&gt; in the mapper XML file. For example as shown below:</p><parameter ac:name="">xml</parameter><plain-text-body>&lt;update id="batchUpdateAccount" parameterType="java.util.Map"&gt;
     update ACCOUNT set
     ACC_EMAIL = #{emailAddress}
     where
     ACC_ID in
-    &lt;foreach item=&quot;Account&quot; collection=&quot;list&quot; open=&quot;(&quot; close=&quot;)&quot; separator=&quot;,&quot;&gt;
+    &lt;foreach item="Account" collection="list" open="(" close=")" separator=","&gt;
         #{Account.id}
     &lt;/foreach&gt;
 &lt;/update&gt;
-]]></script>
-</div></div><p>Then you can update multiple rows, by sending a Camel message to the mybatis endpoint which uses the UpdateList statement type, as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
-    .to(&quot;mybatis:batchUpdateAccount?statementType=UpdateList&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div><h4 id="MyBatis-UsingDeleteListStatementType">Using DeleteList StatementType</h4><p><strong>Available as of Camel 2.11</strong></p><p>MyBatis allows you to delete multiple rows using its for-each batch driver. To use this, you need to use the &lt;foreach&gt; in the mapper XML file. For example as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;delete id=&quot;batchDeleteAccountById&quot; parameterType=&quot;java.util.List&quot;&gt;
+</plain-text-body><p>Then you can update multiple rows, by sending a Camel message to the mybatis endpoint which uses the UpdateList statement type, as shown below:</p><plain-text-body>from("direct:start")
+    .to("mybatis:batchUpdateAccount?statementType=UpdateList")
+    .to("mock:result");
+</plain-text-body><h4 id="MyBatis-UsingDeleteListStatementType">Using DeleteList StatementType</h4><p><strong>Available as of Camel 2.11</strong></p><p>MyBatis allows you to delete multiple rows using its for-each batch driver. To use this, you need to use the &lt;foreach&gt; in the mapper XML file. For example as shown below:</p><parameter ac:name="">xml</parameter><plain-text-body>&lt;delete id="batchDeleteAccountById" parameterType="java.util.List"&gt;
     delete from ACCOUNT
     where
     ACC_ID in
-    &lt;foreach item=&quot;AccountID&quot; collection=&quot;list&quot; open=&quot;(&quot; close=&quot;)&quot; separator=&quot;,&quot;&gt;
+    &lt;foreach item="AccountID" collection="list" open="(" close=")" separator=","&gt;
         #{AccountID}
     &lt;/foreach&gt;
 &lt;/delete&gt;
-]]></script>
-</div></div><p>Then you can delete multiple rows, by sending a Camel message to the mybatis endpoint which uses the DeleteList statement type, as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
-    .to(&quot;mybatis:batchDeleteAccount?statementType=DeleteList&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div><h4 id="MyBatis-NoticeonInsertList,UpdateListandDeleteListStatementTypes">Notice on InsertList, UpdateList and DeleteList StatementTypes</h4><p>Parameter of any type (List, Map, etc.) can be passed to mybatis and an end user is responsible for handling it as required<br clear="none"> with the help of <a shape="rect" class="external-link" href="http://www.mybatis.org/core/dynamic-sql.html" rel="nofollow">mybatis dynamic queries</a> capabilities.</p><h4 id="MyBatis-Scheduledpollingexample">Scheduled polling example</h4><p>This component supports scheduled polling and can therefore be used as a&#160;<a shape="rect" href="polling-consumer.html">Polling Consumer</a>. For example to poll the database every minute:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;mybatis:selectAllAccounts?delay=60000&quot;).to(&quot;activemq:queue:allAccounts&quot;);]]></script>
-</div></div><p>See "ScheduledPollConsumer Options" on&#160;<a shape="rect" href="polling-consumer.html">Polling Consumer</a> for more options.</p><p>Alternatively you can use another mechanism for triggering the scheduled polls, such as the <a shape="rect" href="timer.html">Timer</a> or <a shape="rect" href="quartz.html">Quartz</a> components.&#160;<span style="line-height: 1.4285715;">In the sample below we poll the database, every 30 seconds using the </span><a shape="rect" href="timer.html">Timer</a><span style="line-height: 1.4285715;"> component and send the data to the JMS queue:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;timer://pollTheDatabase?delay=30000&quot;).to(&quot;mybatis:selectAllAccounts&quot;).to(&quot;activemq:queue:allAccounts&quot;);
-]]></script>
-</div></div><p>And the MyBatis SQL mapping file used:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[  &lt;!-- Select with no parameters using the result map for Account class. --&gt;
-  &lt;select id=&quot;selectAllAccounts&quot; resultMap=&quot;AccountResult&quot;&gt;
+</plain-text-body><p>Then you can delete multiple rows, by sending a Camel message to the mybatis endpoint which uses the DeleteList statement type, as shown below:</p><plain-text-body>from("direct:start")
+    .to("mybatis:batchDeleteAccount?statementType=DeleteList")
+    .to("mock:result");
+</plain-text-body><h4 id="MyBatis-NoticeonInsertList,UpdateListandDeleteListStatementTypes">Notice on InsertList, UpdateList and DeleteList StatementTypes</h4><p>Parameter of any type (List, Map, etc.) can be passed to mybatis and an end user is responsible for handling it as required<br clear="none"> with the help of <a shape="rect" class="external-link" href="http://www.mybatis.org/core/dynamic-sql.html" rel="nofollow">mybatis dynamic queries</a> capabilities.</p><h4 id="MyBatis-Scheduledpollingexample">Scheduled polling example</h4><p>This component supports scheduled polling and can therefore be used as a&#160;<a shape="rect" href="polling-consumer.html">Polling Consumer</a>. For example to poll the database every minute:</p><plain-text-body>from("mybatis:selectAllAccounts?delay=60000").to("activemq:queue:allAccounts");</plain-text-body><p>See "ScheduledPollConsumer Options" on&#160;<a shape="rect" href="polling-consumer.html">Polling Consumer</a> for more options.</p><p>Alterna
 tively you can use another mechanism for triggering the scheduled polls, such as the <a shape="rect" href="timer.html">Timer</a> or <a shape="rect" href="quartz.html">Quartz</a> components.&#160;<span style="line-height: 1.4285715;">In the sample below we poll the database, every 30 seconds using the </span><a shape="rect" href="timer.html">Timer</a><span style="line-height: 1.4285715;"> component and send the data to the JMS queue:</span></p><parameter ac:name="">java</parameter><plain-text-body>from("timer://pollTheDatabase?delay=30000").to("mybatis:selectAllAccounts").to("activemq:queue:allAccounts");
+</plain-text-body><p>And the MyBatis SQL mapping file used:</p><parameter ac:name="">xml</parameter><plain-text-body>  &lt;!-- Select with no parameters using the result map for Account class. --&gt;
+  &lt;select id="selectAllAccounts" resultMap="AccountResult"&gt;
     select * from ACCOUNT
   &lt;/select&gt;
-]]></script>
-</div></div><h4 id="MyBatis-UsingonConsume">Using onConsume</h4><p>This component supports executing statements <strong>after</strong> data have been consumed and processed by Camel. This allows you to do post updates in the database. Notice all statements must be <code>UPDATE</code> statements. Camel supports executing multiple statements whose names should be separated by commas.</p><p>The route below illustrates we execute the <strong>consumeAccount</strong> statement data is processed. This allows us to change the status of the row in the database to processed, so we avoid consuming it twice or more.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-from(&quot;mybatis:selectUnprocessedAccounts?consumer.onConsume=consumeAccount&quot;).to(&quot;mock:results&quot;);
-]]></script>
-</div></div>And the statements in the sqlmap file:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-&lt;select id=&quot;selectUnprocessedAccounts&quot; resultMap=&quot;AccountResult&quot;&gt;
-    select * from ACCOUNT where PROCESSED = false
-&lt;/select&gt;
-]]></script>
-</div></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-&lt;update id=&quot;consumeAccount&quot; parameterType=&quot;Account&quot;&gt;
-    update ACCOUNT set PROCESSED = true where ACC_ID = #{id}
-&lt;/update&gt;
-]]></script>
-</div></div><h4 id="MyBatis-Participatingintransactions"><span style="line-height: 1.5;">Participating in transactions</span></h4><p>Setting up a transaction manager under camel-mybatis can be a little bit fiddly, as it involves externalising the database configuration outside the standard MyBatis <code>SqlMapConfig.xml</code> file.</p><p>The first part requires the setup of a <code>DataSource</code>. This is typically a pool (either DBCP, or c3p0), which needs to be wrapped in a Spring proxy. This proxy enables non-Spring use of the <code>DataSource</code> to participate in Spring transactions (the MyBatis <code>SqlSessionFactory</code> does just this).</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[    &lt;bean id=&quot;dataSource&quot; class=&quot;org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy&quot;&gt;
+</plain-text-body><h4 id="MyBatis-UsingonConsume">Using onConsume</h4><p>This component supports executing statements <strong>after</strong> data have been consumed and processed by Camel. This allows you to do post updates in the database. Notice all statements must be <code>UPDATE</code> statements. Camel supports executing multiple statements whose names should be separated by commas.</p><p>The route below illustrates we execute the <strong>consumeAccount</strong> statement data is processed. This allows us to change the status of the row in the database to processed, so we avoid consuming it twice or more.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-mybatis/src/test/java/org/apache/camel/component/mybatis/MyBatisQueueTest.java}</plain-text-body>And the statements in the sqlmap file:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-mybatis/src/test/resources/org/apache/camel/component/mybatis/Account.xml}</plain-text-body><pla
 in-text-body>{snippet:id=e2|lang=xml|url=camel/trunk/components/camel-mybatis/src/test/resources/org/apache/camel/component/mybatis/Account.xml}</plain-text-body></p><h4 id="MyBatis-Participatingintransactions"><span style="line-height: 1.5;">Participating in transactions</span></h4><p>Setting up a transaction manager under camel-mybatis can be a little bit fiddly, as it involves externalising the database configuration outside the standard MyBatis <code>SqlMapConfig.xml</code> file.</p><p>The first part requires the setup of a <code>DataSource</code>. This is typically a pool (either DBCP, or c3p0), which needs to be wrapped in a Spring proxy. This proxy enables non-Spring use of the <code>DataSource</code> to participate in Spring transactions (the MyBatis <code>SqlSessionFactory</code> does just this).</p><parameter ac:name="">xml</parameter><plain-text-body>    &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"&gt;
         &lt;constructor-arg&gt;
-            &lt;bean class=&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;&gt;
-                &lt;property name=&quot;driverClass&quot; value=&quot;org.postgresql.Driver&quot;/&gt;
-                &lt;property name=&quot;jdbcUrl&quot; value=&quot;jdbc:postgresql://localhost:5432/myDatabase&quot;/&gt;
-                &lt;property name=&quot;user&quot; value=&quot;myUser&quot;/&gt;
-                &lt;property name=&quot;password&quot; value=&quot;myPassword&quot;/&gt;
+            &lt;bean class="com.mchange.v2.c3p0.ComboPooledDataSource"&gt;
+                &lt;property name="driverClass" value="org.postgresql.Driver"/&gt;
+                &lt;property name="jdbcUrl" value="jdbc:postgresql://localhost:5432/myDatabase"/&gt;
+                &lt;property name="user" value="myUser"/&gt;
+                &lt;property name="password" value="myPassword"/&gt;
             &lt;/bean&gt;
         &lt;/constructor-arg&gt;
     &lt;/bean&gt;
-]]></script>
-</div></div><p>This has the additional benefit of enabling the database configuration to be externalised using property placeholders.</p><p>A transaction manager is then configured to manage the outermost <code>DataSource</code>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[    &lt;bean id=&quot;txManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&gt;
-        &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot;/&gt;
+</plain-text-body><p>This has the additional benefit of enabling the database configuration to be externalised using property placeholders.</p><p>A transaction manager is then configured to manage the outermost <code>DataSource</code>:</p><parameter ac:name="">xml</parameter><plain-text-body>    &lt;bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
+        &lt;property name="dataSource" ref="dataSource"/&gt;
     &lt;/bean&gt;
-]]></script>
-</div></div><p>A <a shape="rect" class="external-link" href="http://www.mybatis.org/spring/index.html" rel="nofollow">mybatis-spring</a> <a shape="rect" class="external-link" href="http://www.mybatis.org/spring/factorybean.html" rel="nofollow"><code>SqlSessionFactoryBean</code></a> then wraps that same <code>DataSource</code>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[    &lt;bean id=&quot;sqlSessionFactory&quot; class=&quot;org.mybatis.spring.SqlSessionFactoryBean&quot;&gt;
-        &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot;/&gt;
+</plain-text-body><p>A <a shape="rect" class="external-link" href="http://www.mybatis.org/spring/index.html" rel="nofollow">mybatis-spring</a> <a shape="rect" class="external-link" href="http://www.mybatis.org/spring/factorybean.html" rel="nofollow"><code>SqlSessionFactoryBean</code></a> then wraps that same <code>DataSource</code>:</p><parameter ac:name="">xml</parameter><plain-text-body>    &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
+        &lt;property name="dataSource" ref="dataSource"/&gt;
         &lt;!-- standard mybatis config file --&gt;
-	&lt;property name=&quot;configLocation&quot; value=&quot;/META-INF/SqlMapConfig.xml&quot;/&gt;
+	&lt;property name="configLocation" value="/META-INF/SqlMapConfig.xml"/&gt;
         &lt;!-- externalised mappers --&gt;
-	&lt;property name=&quot;mapperLocations&quot; value=&quot;classpath*:META-INF/mappers/**/*.xml&quot;/&gt;
+	&lt;property name="mapperLocations" value="classpath*:META-INF/mappers/**/*.xml"/&gt;
     &lt;/bean&gt;
-]]></script>
-</div></div><p>The camel-mybatis component is then configured with that factory:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[    &lt;bean id=&quot;mybatis&quot; class=&quot;org.apache.camel.component.mybatis.MyBatisComponent&quot;&gt;
-        &lt;property name=&quot;sqlSessionFactory&quot; ref=&quot;sqlSessionFactory&quot;/&gt;
+</plain-text-body><p>The camel-mybatis component is then configured with that factory:</p><parameter ac:name="">xml</parameter><plain-text-body>    &lt;bean id="mybatis" class="org.apache.camel.component.mybatis.MyBatisComponent"&gt;
+        &lt;property name="sqlSessionFactory" ref="sqlSessionFactory"/&gt;
     &lt;/bean&gt;
-]]></script>
-</div></div><p>Finally, a <a shape="rect" href="transactional-client.html">transaction policy</a> is defined over the top of the transaction manager, which can then be used as usual:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[    &lt;bean id=&quot;PROPAGATION_REQUIRED&quot; class=&quot;org.apache.camel.spring.spi.SpringTransactionPolicy&quot;&gt;
-        &lt;property name=&quot;transactionManager&quot; ref=&quot;txManager&quot;/&gt;
-        &lt;property name=&quot;propagationBehaviorName&quot; value=&quot;PROPAGATION_REQUIRED&quot;/&gt;
+</plain-text-body><p>Finally, a <a shape="rect" href="transactional-client.html">transaction policy</a> is defined over the top of the transaction manager, which can then be used as usual:</p><parameter ac:name="">xml</parameter><plain-text-body>    &lt;bean id="PROPAGATION_REQUIRED" class="org.apache.camel.spring.spi.SpringTransactionPolicy"&gt;
+        &lt;property name="transactionManager" ref="txManager"/&gt;
+        &lt;property name="propagationBehaviorName" value="PROPAGATION_REQUIRED"/&gt;
     &lt;/bean&gt;
 
-    &lt;camelContext id=&quot;my-model-context&quot; xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
-        &lt;route id=&quot;insertModel&quot;&gt;
-            &lt;from uri=&quot;direct:insert&quot;/&gt;
-            &lt;transacted ref=&quot;PROPAGATION_REQUIRED&quot;/&gt;
-            &lt;to uri=&quot;mybatis:myModel.insert?statementType=Insert&quot;/&gt;
+    &lt;camelContext id="my-model-context" xmlns="http://camel.apache.org/schema/spring"&gt;
+        &lt;route id="insertModel"&gt;
+            &lt;from uri="direct:insert"/&gt;
+            &lt;transacted ref="PROPAGATION_REQUIRED"/&gt;
+            &lt;to uri="mybatis:myModel.insert?statementType=Insert"/&gt;
         &lt;/route&gt;
     &lt;/camelContext&gt;
-]]></script>
-</div></div><p></p><h3 id="MyBatis-SeeAlso">See Also</h3>
-<ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul></div>
+</plain-text-body><p><parameter ac:name=""><a shape="rect" href="endpoint-see-also.html">Endpoint See Also</a></parameter></p></div>
         </td>
         <td valign="top">
           <div class="navigation">