camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r894976 - in /websites/production/camel/content: cache/main.pageCache mybatis.html
Date Tue, 21 Jan 2014 15:19:53 GMT
Author: buildbot
Date: Tue Jan 21 15:19:52 2014
New Revision: 894976

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/mybatis.html

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/mybatis.html
==============================================================================
--- websites/production/camel/content/mybatis.html (original)
+++ websites/production/camel/content/mybatis.html Tue Jan 21 15:19:52 2014
@@ -86,69 +86,27 @@
 	<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="theme: Default; brush: xml; gutter: false" 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><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-mybatis:statementName[?options]
+</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="theme: Default; brush: java; gutter: false" 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></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">
 <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 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="confluence
 Td"><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>InsertList</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> An integer
to define the maximum messages to gather per poll. 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></tbody></tab
 le>
-</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><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">
 <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>
-
-<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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-from(&quot;activemq:queue:newAccount&quot;).
+</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="theme: Default; brush: java; gutter: false" 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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-  &lt;!-- Insert example, using the Account parameter class --&gt;
+</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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
 &lt;!-- Insert example, using the Account parameter class --&gt;
   &lt;insert id=&quot;insertAccount&quot; parameterType=&quot;Account&quot;&gt;
     insert into ACCOUNT (
       ACC_ID,
@@ -161,43 +119,25 @@ from(&quot;activemq:queue:newAccount&quo
     )
   &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">
+</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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;)
     .to(&quot;mybatis:selectAccountById?statementType=SelectOne&quot;)
     .to(&quot;mock:result&quot;);
 ]]></script>
-</div></div>
-
-<p>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>:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+</div></div><p>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>:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;)
     .to(&quot;mybatis:selectAllAccounts?statementType=SelectList&quot;)
     .to(&quot;mock:result&quot;);
 ]]></script>
-</div></div>
-
-<p>And the same for <code>UPDATE</code>, where we can send an <code>Account</code>
object as the IN body to MyBatis:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+</div></div><p>And the same for <code>UPDATE</code>, where
we can send an <code>Account</code> object as the IN body to MyBatis:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
 <script class="theme: Default; brush: java; gutter: false" 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">
+</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="theme: Default; brush: xml; gutter: false" 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;
@@ -214,25 +154,14 @@ from(&quot;direct:start&quot;)
     )
 &lt;/insert&gt;
 ]]></script>
-</div></div>
-
-<p>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:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+</div></div><p>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:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" 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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;update id=&quot;batchUpdateAccount&quot; parameterType=&quot;java.util.Map&quot;&gt;
+</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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;update
id=&quot;batchUpdateAccount&quot; parameterType=&quot;java.util.Map&quot;&gt;
     update ACCOUNT set
     ACC_EMAIL = #{emailAddress}
     where
@@ -242,25 +171,13 @@ from(&quot;direct:start&quot;)
     &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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
+</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="theme: Default; brush: java; gutter: false" 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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-&lt;delete id=&quot;batchDeleteAccountById&quot; parameterType=&quot;java.util.List&quot;&gt;
+</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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[&lt;delete
id=&quot;batchDeleteAccountById&quot; parameterType=&quot;java.util.List&quot;&gt;
     delete from ACCOUNT
     where
     ACC_ID in
@@ -269,77 +186,40 @@ from(&quot;direct:start&quot;)
     &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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
+</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="theme: Default; brush: java; gutter: false" 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>Since this component does not support scheduled polling, you need to 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.</p>
-
-<p>In the sample below we poll the database, every 30 seconds using the <a shape="rect"
href="timer.html">Timer</a> component and send the data to the JMS queue:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
-from(&quot;timer://pollTheDatabase?delay=30000&quot;).to(&quot;mbatis:selectAllAccounts&quot;).to(&quot;activemq:queue:allAccounts&quot;);
+</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="theme: Default; brush: java; gutter: false" 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="theme: Default; brush: java; gutter: false" 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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-  &lt;!-- Select with no parameters using the result map for Account class. --&gt;
+</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="theme: Default; brush: xml; gutter: false" 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;
     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">
+</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="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
 from(&quot;mybatis:selectUnprocessedAccounts?consumer.onConsume=consumeAccount&quot;).to(&quot;mock:results&quot;);
 ]]></script>
-</div></div>
-
-<p>And the statements in the sqlmap file:</p>
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+</div></div><p>And the statements in the sqlmap file:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
 <script class="theme: Default; brush: xml; gutter: false" 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">
+</div></div><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
 <script class="theme: Default; brush: xml; gutter: false" 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">Participating in transactions</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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-    &lt;bean id=&quot;dataSource&quot; class=&quot;org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy&quot;&gt;
+</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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
   &lt;bean id=&quot;dataSource&quot; class=&quot;org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy&quot;&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;
@@ -350,25 +230,13 @@ from(&quot;mybatis:selectUnprocessedAcco
         &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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-    &lt;bean id=&quot;txManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&gt;
+</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="theme: Default; brush: xml; gutter: false" 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;
     &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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-    &lt;bean id=&quot;sqlSessionFactory&quot; class=&quot;org.mybatis.spring.SqlSessionFactoryBean&quot;&gt;
+</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="theme: Default; brush: xml; gutter: false" 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;
         &lt;!-- standard mybatis config file --&gt;
 	&lt;property name=&quot;configLocation&quot; value=&quot;/META-INF/SqlMapConfig.xml&quot;/&gt;
@@ -376,23 +244,13 @@ from(&quot;mybatis:selectUnprocessedAcco
 	&lt;property name=&quot;mapperLocations&quot; value=&quot;classpath*:META-INF/mappers/**/*.xml&quot;/&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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-    &lt;bean id=&quot;mybatis&quot; class=&quot;org.apache.camel.component.mybatis.MyBatisComponent&quot;&gt;
+</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="theme: Default; brush: xml; gutter: false" 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;
     &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="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
-    &lt;bean id=&quot;PROPAGATION_REQUIRED&quot; class=&quot;org.apache.camel.spring.spi.SpringTransactionPolicy&quot;&gt;
+</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="theme: Default; brush: xml; gutter: false" 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;
     &lt;/bean&gt;
@@ -405,9 +263,7 @@ from(&quot;mybatis:selectUnprocessedAcco
         &lt;/route&gt;
     &lt;/camelContext&gt;
 ]]></script>
-</div></div>
-
-<h3 id="MyBatis-SeeAlso">See Also</h3>
+</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>
         </td>
         <td valign="top">



Mime
View raw message