Modified: websites/production/camel/content/jpa.html
==============================================================================
--- websites/production/camel/content/jpa.html (original)
+++ websites/production/camel/content/jpa.html Tue Mar 14 11:20:07 2017
@@ -94,10 +94,10 @@
     <!-- use the same version as your Camel core version -->
 </dependency>
 ]]></script>
-</div></div><p>Sending to the endpoint</p><p>You can store a Java entity bean 
in a database by sending it to a JPA producer endpoint. The body of the 
<em>In</em> message is assumed to be an entity bean (that is, a POJO with an <a 
shape="rect" class="external-link" 
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html"; 
rel="nofollow">@Entity</a> annotation on it) or a collection or array of entity 
beans.</p><p>If the body is a List of entities, make sure to use 
<strong>entityType=java.util.ArrayList</strong> as a configuration passed to 
the producer endpoint.</p><p>If the body does not contain one of the previous 
listed types, put a <a shape="rect" href="message-translator.html">Message 
Translator</a> in front of the endpoint to perform the necessary conversion 
first.</p><h3 id="JPA-Consumingfromtheendpoint">Consuming from the 
endpoint</h3><p>Consuming messages from a JPA consumer endpoint removes (or 
updates) entity beans in the database. This allows you to use a
  database table as a logical queue: consumers take messages from the queue and 
then delete/update them to logically remove them from the queue.</p><p>If you 
do not wish to delete the entity bean when it has been processed (and when 
routing is done), you can specify <code>consumeDelete=false</code> on the URI. 
This will result in the entity being processed each poll.</p><p>If you would 
rather perform some update on the entity to mark it as processed (such as to 
exclude it from a future query) then you can annotate a method with <a 
shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html";>@Consumed</a>
 which will be invoked on your entity bean when the entity bean when it has 
been processed (and when routing is done).</p><p>From <strong>Camel 
2.13</strong> onwards you can use <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/
 jpa/PreConsumed.html">@PreConsumed</a> which will be invoked on your entity 
bean before it has been processed (before routing).</p><p>If you are consuming 
a lot (100K+) of rows and experience OutOfMemory problems you should set the 
maximumResults to sensible value.</p><p><strong>Note:</strong> Since 
<strong>Camel 2.18</strong>, JPA now includes a <code>JpaPollingConsumer</code> 
implementation that better supports Content Enricher using 
<code>pollEnrich()</code> to do an on-demand poll that returns either none, one 
or a list of entities as the result.</p><h3 id="JPA-URIformat">URI 
format</h3><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+</div></div><p>Sending to the endpoint</p><p>You can store a Java entity bean 
in a database by sending it to a JPA producer endpoint. The body of the 
<em>In</em> message is assumed to be an entity bean (that is, a POJO with an <a 
shape="rect" class="external-link" 
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html"; 
rel="nofollow">@Entity</a> annotation on it) or a collection or array of entity 
beans.</p><p>If the body is a List of entities, make sure to use 
<strong>entityType=java.util.ArrayList</strong> as a configuration passed to 
the producer endpoint.</p><p>If the body does not contain one of the previous 
listed types, put a <a shape="rect" href="message-translator.html">Message 
Translator</a> in front of the endpoint to perform the necessary conversion 
first.</p><p>From&#160;<strong>Camel 2.19</strong>&#160;onwards you can use 
<strong>query</strong>, <strong>namedQuery</strong> and 
<strong>nativeQuery&#160;</strong>option for the producer as well to retri
 eve a set of entities or execute bulk update/delete.</p><h3 
id="JPA-Consumingfromtheendpoint">Consuming from the endpoint</h3><p>Consuming 
messages from a JPA consumer endpoint removes (or updates) entity beans in the 
database. This allows you to use a database table as a logical queue: consumers 
take messages from the queue and then delete/update them to logically remove 
them from the queue.</p><p>If you do not wish to delete the entity bean when it 
has been processed (and when routing is done), you can specify 
<code>consumeDelete=false</code> on the URI. This will result in the entity 
being processed each poll.</p><p>If you would rather perform some update on the 
entity to mark it as processed (such as to exclude it from a future query) then 
you can annotate a method with <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html";>@Consumed</a>
 which will be invoked on your entity bean when the e
 ntity bean when it has been processed (and when routing is done).</p><p>From 
<strong>Camel 2.13</strong> onwards you can use <a shape="rect" 
class="external-link" 
href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/PreConsumed.html";>@PreConsumed</a>
 which will be invoked on your entity bean before it has been processed (before 
routing).</p><p>If you are consuming a lot (100K+) of rows and experience 
OutOfMemory problems you should set the maximumResults to sensible 
value.</p><p><strong>Note:</strong> Since <strong>Camel 2.18</strong>, JPA now 
includes a <code>JpaPollingConsumer</code> implementation that better supports 
Content Enricher using <code>pollEnrich()</code> to do an on-demand poll that 
returns either none, one or a list of entities as the 
result.</p><p>&#160;</p><h3 id="JPA-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[jpa:entityClassName[?options]
 ]]></script>
-</div></div><p>For sending to the endpoint, the <em>entityClassName</em> is 
optional. If specified, it helps the <a shape="rect" 
href="type-converter.html">Type Converter</a> to ensure the body is of the 
correct type.</p><p>For consuming, the <em>entityClassName</em> is 
mandatory.</p><p>You can append query options to the URI in the following 
format, <code>?option=value&amp;option=value&amp;...</code></p><h3 
id="JPA-Options">Options</h3><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>entityType</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><em>entityClassName</em></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Overrides the <em>entityClassName</em> from 
the U
 RI.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>persistenceUnit</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>camel</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>The JPA persistence unit used by 
default.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumeDelete</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> If 
<code>true</code>, the entity is deleted after it is consumed; if 
<code>false</code>, the entity is not deleted.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>consumeLockEntity</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer 
only:</strong> Specifies whether or not to set an exclusive lock on e
 ach entity bean while processing the results from 
polling.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>flushOnSend</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA producer only:</strong> Flushes 
the <a shape="rect" class="external-link" 
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html";
 rel="nofollow">EntityManager</a> after the entity bean has been 
persisted.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>maximumResults</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> Set the 
maximum number of results to retrieve on the <a shape="rect" 
class="external-link" 
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html"; 
rel="nofollow">Query</a>.</p>
 </td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>transactionManager</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>This option is <a shape="rect" 
href="registry.html">Registry</a> based which requires the <code>#</code> 
notation so that the given <code>transactionManager</code> being specified can 
be looked up properly, e.g. 
<code>transactionManager=#myTransactionManager</code>. It specifies the 
transaction manager to use. If none provided, Camel will use a 
<code>JpaTransactionManager</code> by default. Can be used to set a JTA 
transaction manager (for integration with an EJB 
container).</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.delay</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>500</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> Delay 
in mi
 lliseconds between each poll.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.initialDelay</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer 
only:</strong> Milliseconds before polling starts.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.useFixedDelay</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer 
only:</strong> Set to <code>true</code> to use fixed delay between polls, 
otherwise fixed rate is used. See <a shape="rect" class="external-link" 
href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html";
 rel="nofollow">ScheduledExecutorService</a> in JDK for 
details.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>maxMe
 ssagesPerPoll</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>JPA consumer only:</strong> An integer value to 
define the maximum number of messages to gather per poll. By default, no 
maximum is set. Can be used to avoid polling many thousands of messages when 
starting up the server. Set a value of 0 or negative to 
disable.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.query</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>JPA consumer only:</strong> To use a custom 
query when consuming data.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.namedQuery</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> To
  use a named query when consuming data.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>consumer.nativeQuery</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> To use 
a custom native query when consuming data. You may want to use the option 
<code>consumer.resultClass</code> also when using native 
queries.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.parameters</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA consumer 
only:</strong> This option is <a shape="rect" href="registry.html">Registry</a> 
based which requires the <code>#</code> notation. This key/value mapping is 
used for building the query parameters. It's is expected to be of the generic 
type <code>java.util.Map&lt;String, Object&gt;</
 code> where the keys are the named parameters of a given JPA query and the 
values are their corresponding effective values you want to select 
for.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.resultClass</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.7: JPA consumer 
only:</strong> Defines the type of the returned payload (we will call 
<code>entityManager.createNativeQuery(nativeQuery, resultClass)</code> instead 
of <code>entityManager.createNativeQuery(nativeQuery)</code>). Without this 
option, we will return an object array. Only has an affect when using in 
conjunction with native query when consuming data.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.transacted</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><
 p><strong>Camel 2.7.5/2.8.3/2.9: JPA consumer only:</strong> Whether to run 
the consumer in transacted mode, by which all messages will either commit or 
rollback, when the entire batch has been processed. The default behavior 
(false) is to commit all the previously successfully processed messages, and 
only rollback the last failed message.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>consumer.lockModeType</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>WRITE</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 
2.11.2/2.12:</strong> To configure the lock mode on the consumer. The possible 
values is defined in the enum <code>javax.persistence.LockModeType</code>. The 
default value is changed to <code>PESSIMISTIC_WRITE</code> since <strong>Camel 
2.13</strong>.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.SkipLockedEntity</code></p></td><td 
colspan="1" rowspan="1" cl
 ass="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.13:</strong> To configure whether to 
use NOWAIT on lock and silently skip the entity.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>usePersist</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.5: JPA producer 
only:</strong> Indicates to use <code>entityManager.persist(entity)</code> 
instead of <code>entityManager.merge(entity)</code>. Note: 
<code>entityManager.persist(entity)</code> doesn't work for detached entities 
(where the EntityManager has to execute an UPDATE instead of an INSERT 
query)!</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>joinTransaction</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><st
 rong>Camel 2.12.3:</strong> camel-jpa will join transaction by default from 
Camel 2.12 onwards. You can use this option to turn this off, for example if 
you use LOCAL_RESOURCE and join transaction doesn't work with your JPA 
provider. This option can also be set globally on the 
<code>JpaComponent</code>, instead of having to set it on all 
endpoints.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p 
class="p1">usePassedInEntityManager</p></td><td colspan="1" rowspan="1" 
class="confluenceTd">false</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.12.4/2.13.1 JPA producer only:</strong> If 
set to true, then Camel will use the EntityManager from the header<p 
class="p1">JpaConstants.ENTITYMANAGER instead of the configured entity manager 
on the component/endpoint. This allows end users to control which entity 
manager will be in use.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">sharedEntityManager</td><td colspan="1" rowspan="1" cla
 ss="confluenceTd">false</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.16:</strong>&#160;whether to use spring's 
SharedEntityManager for the consumer/producer. A good idea may be to set 
joinTransaction=false if this option is true, as sharing the entity manager and 
mixing transactions is not a good idea.</td></tr></tbody></table></div><h3 
id="JPA-MessageHeaders">Message Headers</h3><p>Camel adds the following message 
headers to the exchange:</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>CamelJpaTemplate</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>JpaTemplate</code></p></td><td colspan="1" 
rowspan="1" class="con
 fluenceTd"><p><strong>Not supported anymore since Camel 2.12:</strong> The 
<code>JpaTemplate</code> object that is used to access the entity bean. You 
need this object in some situations, for instance in a type converter or when 
you are doing some custom processing. See <a shape="rect" class="external-link" 
href="https://issues.apache.org/jira/browse/CAMEL-5932";>CAMEL-5932</a> for the 
reason why the support for this header has been dropped.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>CamelEntityManager</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>EntityManager</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA 
consumer / Camel 2.12.2: JPA producer:</strong> The JPA 
<code>EntityManager</code> object being used by <code>JpaConsumer</code> or 
<code>JpaProducer</code>.</p></td></tr></tbody></table></div></div>
+</div></div><p>For sending to the endpoint, the <em>entityClassName</em> is 
optional. If specified, it helps the <a shape="rect" 
href="type-converter.html">Type Converter</a> to ensure the body is of the 
correct type.</p><p>For consuming, the <em>entityClassName</em> is 
mandatory.</p><p>You can append query options to the URI in the following 
format, <code>?option=value&amp;option=value&amp;...</code></p><h3 
id="JPA-Options">Options</h3><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>entityType</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><em>entityClassName</em></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Overrides the <em>entityClassName</em> from 
the U
 RI.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>persistenceUnit</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>camel</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>The JPA persistence unit used by 
default.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumeDelete</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> If 
<code>true</code>, the entity is deleted after it is consumed; if 
<code>false</code>, the entity is not deleted.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>consumeLockEntity</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer 
only:</strong> Specifies whether or not to set an exclusive lock on e
 ach entity bean while processing the results from 
polling.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>flushOnSend</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA producer only:</strong> Flushes 
the <a shape="rect" class="external-link" 
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html";
 rel="nofollow">EntityManager</a> after the entity bean has been 
persisted.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>maximumResults</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> Set the 
maximum number of results to retrieve on the <a shape="rect" 
class="external-link" 
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html"; 
rel="nofollow">Query</a>. <st
 rong>Camel 2.19:</strong><span> it's also used for the producer when it 
executes a query.</span></p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>transactionManager</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>This option is <a shape="rect" 
href="registry.html">Registry</a> based which requires the <code>#</code> 
notation so that the given <code>transactionManager</code> being specified can 
be looked up properly, e.g. 
<code>transactionManager=#myTransactionManager</code>. It specifies the 
transaction manager to use. If none provided, Camel will use a 
<code>JpaTransactionManager</code> by default. Can be used to set a JTA 
transaction manager (for integration with an EJB 
container).</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.delay</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>500</code></p></td
 ><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer 
 >only:</strong> Delay in milliseconds between each poll.</p></td></tr><tr><td 
 >colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>consumer.initialDelay</code></p></td><td 
 >colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td 
 >colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA consumer 
 >only:</strong> Milliseconds before polling starts.</p></td></tr><tr><td 
 >colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>consumer.useFixedDelay</code></p></td><td 
 >colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>false</code></p></td><td colspan="1" 
 >rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> Set 
 >to <code>true</code> to use fixed delay between polls, otherwise fixed rate 
 >is used. See <a shape="rect" class="external-link" 
 >href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html";
 > rel="nofollow">ScheduledExecutorService</a> 
 in JDK for details.</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>0</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> An 
integer value to define the maximum number of messages to gather per poll. By 
default, no maximum is set. Can be used to avoid polling many thousands of 
messages when starting up the server. Set a value of 0 or negative to 
disable.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.query</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>JPA consumer only:</strong> To use a custom 
query when consuming data.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.namedQuery</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160
 ;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>JPA 
consumer only:</strong> To use a named query when consuming 
data.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.nativeQuery</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>JPA consumer only:</strong> To use 
a custom native query when consuming data. You may want to use the option 
<code>consumer.resultClass</code> also when using native 
queries.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.parameters</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA consumer 
only:</strong> This option is <a shape="rect" href="registry.html">Registry</a> 
based which requires the <code>#</code> notation. This key/value mapping is 
used for building the quer
 y parameters. It's is expected to be of the generic type 
<code>java.util.Map&lt;String, Object&gt;</code> where the keys are the named 
parameters of a given JPA query and the values are their corresponding 
effective values you want to select for.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>consumer.resultClass</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.7: JPA consumer 
only:</strong> Defines the type of the returned payload (we will call 
<code>entityManager.createNativeQuery(nativeQuery, resultClass)</code> instead 
of <code>entityManager.createNativeQuery(nativeQuery)</code>). Without this 
option, we will return an object array. Only has an affect when using in 
conjunction with native query when consuming data.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.transacted</code></p></td><td 
colspan="1" rowspan="1" c
 lass="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.7.5/2.8.3/2.9: JPA consumer 
only:</strong> Whether to run the consumer in transacted mode, by which all 
messages will either commit or rollback, when the entire batch has been 
processed. The default behavior (false) is to commit all the previously 
successfully processed messages, and only rollback the last failed 
message.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>consumer.lockModeType</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>WRITE</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 
2.11.2/2.12:</strong> To configure the lock mode on the consumer. The possible 
values is defined in the enum <code>javax.persistence.LockModeType</code>. The 
default value is changed to <code>PESSIMISTIC_WRITE</code> since <strong>Camel 
2.13</strong>.</p></td></tr><tr><td colspan="1" rowspan="1" c
 lass="confluenceTd"><p><code>consumer.SkipLockedEntity</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.13:</strong> To 
configure whether to use NOWAIT on lock and silently skip the 
entity.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>usePersist</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.5: JPA producer 
only:</strong> Indicates to use <code>entityManager.persist(entity)</code> 
instead of <code>entityManager.merge(entity)</code>. Note: 
<code>entityManager.persist(entity)</code> doesn't work for detached entities 
(where the EntityManager has to execute an UPDATE instead of an INSERT 
query)!</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>joinTransaction</code></p></td><td colspan="1" 
rowspan="1" class
 ="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.12.3:</strong> camel-jpa will join 
transaction by default from Camel 2.12 onwards. You can use this option to turn 
this off, for example if you use LOCAL_RESOURCE and join transaction doesn't 
work with your JPA provider. This option can also be set globally on the 
<code>JpaComponent</code>, instead of having to set it on all 
endpoints.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p 
class="p1">usePassedInEntityManager</p></td><td colspan="1" rowspan="1" 
class="confluenceTd">false</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.12.4/2.13.1 JPA producer only:</strong> If 
set to true, then Camel will use the EntityManager from the header<p 
class="p1">JpaConstants.ENTITYMANAGER instead of the configured entity manager 
on the component/endpoint. This allows end users to control which entity 
manager will be in use.</p></td></tr><tr><td 
 colspan="1" rowspan="1" class="confluenceTd">sharedEntityManager</td><td 
colspan="1" rowspan="1" class="confluenceTd">false</td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.16:</strong>&#160;whether 
to use spring's SharedEntityManager for the consumer/producer. A good idea may 
be to set joinTransaction=false if this option is true, as sharing the entity 
manager and mixing transactions is not a good idea.&#160;</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><span>query</span></td><td 
colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" 
rowspan="1" class="confluenceTd"><span>To use a custom query. <strong>Camel 
2.19:</strong> it can be used for producer as well.</span></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd">namedQuery</td><td colspan="1" 
rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"><span>To use a named query. <strong>Camel 2.19:</strong> 
it can be used fo
 r producer as well.</span></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">nativeQuery</td><td colspan="1" rowspan="1" 
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd">To use a custom native query. <span>You may want to use 
the option </span><code>resultClass</code><span> also when using native 
queries. <strong>Camel 2.19:</strong><span> it can be used for producer as 
well.</span></span></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">parameters</td><td colspan="1" rowspan="1" 
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"><span>This option is </span><a shape="rect" 
href="registry.html">Registry</a><span> based which requires the 
</span><code>#</code><span> notation. This key/value mapping is used for 
building the query parameters. It is expected to be of the generic type 
</span><code>java.util.Map&lt;String, Object&gt;</code><span> where the keys 
are the named parameters of a given JPA que
 ry and the values are their corresponding effective values you want to select 
for. <strong>Camel 2.19:</strong><span> it can be used for producer as well. 
When it's used for producer, <a shape="rect" href="simple.html">Simple</a> 
expression can be used as a parameter value. It allows you to retrieve 
parameter values from the message body header and 
etc.</span></span></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">resultClass</td><td colspan="1" rowspan="1" 
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"><span>Defines the type of the returned payload (we will 
call </span><code>entityManager.createNativeQuery(nativeQuery, 
resultClass)</code><span> instead of 
</span><code>entityManager.createNativeQuery(nativeQuery)</code><span>). 
Without this option, we will return an object array. Only has an affect when 
using in conjunction with native query. <strong>Camel 2.19:</strong><span> it 
can be used for producer as well.</span></span></td></tr
 ><tr><td colspan="1" rowspan="1" class="confluenceTd">useExecuteUpdate</td><td 
 >colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" 
 >rowspan="1" class="confluenceTd"><strong>Camel 2.19: JPA producer 
 >only:</strong><span> To configure whether to use executeUpdate() when 
 >producer executes a query. When you use INSERT, UPDATE or DELETE statement as 
 >a named query, you need to specify this option to 
 >'true'.</span></td></tr></tbody></table></div><h3 
 >id="JPA-MessageHeaders">Message Headers</h3><p>Camel adds the following 
 >message headers to the exchange:</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>CamelJpaTemplate</code></p></td><td 
 >colspan="1" rowsp
 an="1" class="confluenceTd"><p><code>JpaTemplate</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Not supported anymore 
since Camel 2.12:</strong> The <code>JpaTemplate</code> object that is used to 
access the entity bean. You need this object in some situations, for instance 
in a type converter or when you are doing some custom processing. See <a 
shape="rect" class="external-link" 
href="https://issues.apache.org/jira/browse/CAMEL-5932";>CAMEL-5932</a> for the 
reason why the support for this header has been dropped.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>CamelEntityManager</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>EntityManager</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12: JPA 
consumer / Camel 2.12.2: JPA producer:</strong> The JPA 
<code>EntityManager</code> object being used by <code>JpaConsumer</code> or 
<code>JpaProducer</code>.</p></td></tr></tbody
 ></table></div></div>
 
 
 <h3 id="JPA-ConfiguringEntityManagerFactory">Configuring 
EntityManagerFactory</h3><p>Its strongly advised to configure the JPA component 
to use a specific <code>EntityManagerFactory</code> instance. If failed to do 
so each <code>JpaEndpoint</code> will auto create their own instance of 
<code>EntityManagerFactory</code> which most often is not what you 
want.</p><p>For example, you can instantiate a JPA component that references 
the <code>myEMFactory</code> entity manager factory, as follows:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
@@ -130,7 +130,26 @@ public class MultiSteps {
 <script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[from(&quot;jpa://org.apache.camel.examples.MultiSteps?consumer.nativeQuery=select
 * from MultiSteps where step = 1&quot;)
 .to(&quot;bean:myBusinessLogic&quot;);
 ]]></script>
-</div></div><p>If you use the native query option, you will receive an object 
array in the message body.</p><h3 id="JPA-Example">Example</h3><p>See <a 
shape="rect" href="tracer-example.html">Tracer Example</a> for an example using 
<a shape="rect" href="jpa.html">JPA</a> to store traced messages into a 
database.</p><h3 id="JPA-UsingtheJPAbasedidempotentrepository">Using the JPA 
based idempotent repository</h3><p>In this section we will use the JPA based 
idempotent repository.</p><p>First we need to setup a 
<code>persistence-unit</code> in the persistence.xml file:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>If you use the native query option, you will receive an object 
array in the message body.</p><p>&#160;</p><h3 
id="JPA-Usingaproducerwithanamedquery">Using a producer with a named 
query</h3><p>For retrieving selected entities or execute bulk update/delete, 
you can use the&#160;<code>namedQuery</code>&#160;URI query option. First, you 
have to define the named query in the JPA Entity class:</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[@Entity
+@NamedQuery(name = &quot;step1&quot;, query = &quot;select x from MultiSteps x 
where x.step = 1&quot;)
+public class MultiSteps {
+   ...
+}
+]]></script>
+</div></div><p>After that you can define a producer uri like this one:</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:namedQuery&quot;)
+.to(&quot;jpa://org.apache.camel.examples.MultiSteps?namedQuery=step1&quot;);
+]]></script>
+</div></div><h3 id="JPA-Usingaproducerwithaquery">Using a producer with a 
query</h3><p>For retrieving selected entities or execute bulk update/delete, 
you can use the&#160;<code>query</code>&#160;URI query option. You only have to 
define the query option:</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:query&quot;)
+.to(&quot;jpa://org.apache.camel.examples.MultiSteps?query=select o from 
org.apache.camel.examples.MultiSteps o where o.step = 1&quot;);
+]]></script>
+</div></div><h3 id="JPA-Usingaproducerwithanativequery">Using a producer with 
a native query</h3><p>For retrieving selected entities or execute bulk 
update/delete, you can use the&#160;<code>nativeQuery</code>&#160;URI query 
option. You only have to define the native query option:</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:nativeQuery&quot;)
+.to(&quot;jpa://org.apache.camel.examples.MultiSteps?resultClass=org.apache.camel.examples.MultiSteps&amp;nativeQuery=select
 * from MultiSteps where step = 1&quot;);
+]]></script>
+</div></div><p>If you use the native query option without specifying 
<em>resultClass</em>, you will receive an object array in the message 
body.</p><p>&#160;</p><h3 id="JPA-Example">Example</h3><p>See <a shape="rect" 
href="tracer-example.html">Tracer Example</a> for an example using <a 
shape="rect" href="jpa.html">JPA</a> to store traced messages into a 
database.</p><h3 id="JPA-UsingtheJPAbasedidempotentrepository">Using the JPA 
based idempotent repository</h3><p>In this section we will use the JPA based 
idempotent repository.</p><p>First we need to setup a 
<code>persistence-unit</code> in the persistence.xml 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;persistence-unit name=&quot;idempotentDb&quot; 
transaction-type=&quot;RESOURCE_LOCAL&quot;&gt;
   
&lt;class&gt;org.apache.camel.processor.idempotent.jpa.MessageProcessed&lt;/class&gt;


Reply via email to