<commit_before>## JPA Component

*Available as of Camel version 1.0*

The *jpa* component enables you to store and retrieve Java objects from
persistent storage using EJB 3's Java Persistence Architecture (JPA),
which is a standard interface layer that wraps Object/Relational Mapping
(ORM) products such as OpenJPA, Hibernate, TopLink, and so on.

Maven users will need to add the following dependency to their `pom.xml`
for this component:

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jpa</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------

### Sending to the endpoint

You can store a Java entity bean in a database by sending it to a JPA
producer endpoint. The body of the _In_ message is assumed to be an
entity bean (that is, a POJO with an
http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html[@Entity]
annotation on it) or a collection or array of entity beans.

If the body is a List of entities, make sure to use
*entityType=java.util.ArrayList* as a configuration passed to the
producer endpoint.

If the body does not contain one of the previous listed types, put a
link:message-translator.html[Message Translator] in front of the
endpoint to perform the necessary conversion first.

From *Camel 2.19* onwards you can use `query`, `namedQuery` or `nativeQuery`
for the producer as well. Also in the value of the `parameters`, you can use
Simple expression which allows you to retrieve parameter values from Message body, header
and etc. Those query can be used for retrieving a set of data with using `SELECT`
JPQL/SQL statement as well as executing bulk update/delete with using `UPDATE`/`DELETE`
JPQL/SQL statement. Please note that you need to specify `useExecuteUpdate` to `true`
if you execute `UPDATE`/`DELETE` with `namedQuery` as camel don't look into the
named query unlike `query` and `nativeQuery`.


### Consuming from the endpoint

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.

If you do not wish to delete the entity bean when it has been processed
(and when routing is done), you can specify `consumeDelete=false` on the
URI. This will result in the entity being processed each poll.

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
http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html[@Consumed]
which will be invoked on your entity bean when the entity bean when it
has been processed (and when routing is done).

From *Camel 2.13* onwards you can use
http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/PreConsumed.html[@PreConsumed]
which will be invoked on your entity bean before it has been processed
(before routing).

If you are consuming a lot (100K+) of rows and experience OutOfMemory
problems you should set the maximumResults to sensible value.

### URI format

[source,java]
-----------------------------
jpa:entityClassName[?options]
-----------------------------

For sending to the endpoint, the _entityClassName_ is optional. If
specified, it helps the link:type-converter.html[Type Converter] to
ensure the body is of the correct type.

For consuming, the _entityClassName_ is mandatory.

You can append query options to the URI in the following format,
`?option=value&option=value&...`

### Options




// component options: START
The JPA component supports 5 options which are listed below.



[width="100%",cols="2,1,1m,1m,5",options="header"]
|=======================================================================
| Name | Group | Default | Java Type | Description
| entityManagerFactory | common |  | EntityManagerFactory | To use the EntityManagerFactory. This is strongly recommended to configure.
| transactionManager | common |  | PlatformTransactionManager | To use the PlatformTransactionManager for managing transactions.
| joinTransaction | common | true | boolean | The camel-jpa component will join transaction by default. 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 JpaComponent instead of having to set it on all endpoints.
| sharedEntityManager | common | false | boolean | Whether to use Spring's SharedEntityManager for the consumer/producer. Note in most cases joinTransaction should be set to false as this is not an EXTENDED EntityManager.
| resolvePropertyPlaceholders | advanced | true | boolean | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.
|=======================================================================
// component options: END








// endpoint options: START
The JPA endpoint is configured using URI syntax:

    jpa:entityType

with the following path and query parameters:

#### Path Parameters (1 parameters):

[width="100%",cols="2,1,1m,6",options="header"]
|=======================================================================
| Name | Default | Java Type | Description
| entityType |  | Class<?> | *Required* The JPA annotated class to use as entity.
|=======================================================================

#### Query Parameters (42 parameters):

[width="100%",cols="2,1,1m,1m,5",options="header"]
|=======================================================================
| Name | Group | Default | Java Type | Description
| joinTransaction | common | true | boolean | The camel-jpa component will join transaction by default. 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 JpaComponent instead of having to set it on all endpoints.
| maximumResults | common | 1 | int | Set the maximum number of results to retrieve on the Query.
| namedQuery | common |  | String | To use a named query.
| nativeQuery | common |  | String | To use a custom native query. You may want to use the option resultClass also when using native queries.
| parameters | common |  | Map | This key/value mapping is used for building the query parameters. It is expected to be of the generic type java.util.Map 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. When it's used for producer Simple expression can be used as a parameter value. It allows you to retrieve parameter values from the message body header and etc.
| persistenceUnit | common | camel | String | *Required* The JPA persistence unit used by default.
| query | common |  | String | To use a custom query.
| resultClass | common |  | Class<?> | Defines the type of the returned payload (we will call entityManager.createNativeQuery(nativeQuery resultClass) instead of entityManager.createNativeQuery(nativeQuery)). Without this option we will return an object array. Only has an affect when using in conjunction with native query when consuming data.<commit_msg>CAMEL-10265: Regen docs<commit_after>## JPA Component

*Available as of Camel version 1.0*

The *jpa* component enables you to store and retrieve Java objects from
persistent storage using EJB 3's Java Persistence Architecture (JPA),
which is a standard interface layer that wraps Object/Relational Mapping
(ORM) products such as OpenJPA, Hibernate, TopLink, and so on.

Maven users will need to add the following dependency to their `pom.xml`
for this component:

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jpa</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------

### Sending to the endpoint

You can store a Java entity bean in a database by sending it to a JPA
producer endpoint. The body of the _In_ message is assumed to be an
entity bean (that is, a POJO with an
http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html[@Entity]
annotation on it) or a collection or array of entity beans.

If the body is a List of entities, make sure to use
*entityType=java.util.ArrayList* as a configuration passed to the
producer endpoint.

If the body does not contain one of the previous listed types, put a
link:message-translator.html[Message Translator] in front of the
endpoint to perform the necessary conversion first.

From *Camel 2.19* onwards you can use `query`, `namedQuery` or `nativeQuery`
for the producer as well. Also in the value of the `parameters`, you can use
Simple expression which allows you to retrieve parameter values from Message body, header
and etc. Those query can be used for retrieving a set of data with using `SELECT`
JPQL/SQL statement as well as executing bulk update/delete with using `UPDATE`/`DELETE`
JPQL/SQL statement. Please note that you need to specify `useExecuteUpdate` to `true`
if you execute `UPDATE`/`DELETE` with `namedQuery` as camel don't look into the
named query unlike `query` and `nativeQuery`.


### Consuming from the endpoint

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.

If you do not wish to delete the entity bean when it has been processed
(and when routing is done), you can specify `consumeDelete=false` on the
URI. This will result in the entity being processed each poll.

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
http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html[@Consumed]
which will be invoked on your entity bean when the entity bean when it
has been processed (and when routing is done).

From *Camel 2.13* onwards you can use
http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/PreConsumed.html[@PreConsumed]
which will be invoked on your entity bean before it has been processed
(before routing).

If you are consuming a lot (100K+) of rows and experience OutOfMemory
problems you should set the maximumResults to sensible value.

### URI format

[source,java]
-----------------------------
jpa:entityClassName[?options]
-----------------------------

For sending to the endpoint, the _entityClassName_ is optional. If
specified, it helps the link:type-converter.html[Type Converter] to
ensure the body is of the correct type.

For consuming, the _entityClassName_ is mandatory.

You can append query options to the URI in the following format,
`?option=value&option=value&...`

### Options




// component options: START
The JPA component supports 5 options which are listed below.



[width="100%",cols="2,1,1m,1m,5",options="header"]
|=======================================================================
| Name | Group | Default | Java Type | Description
| entityManagerFactory | common |  | EntityManagerFactory | To use the EntityManagerFactory. This is strongly recommended to configure.
| transactionManager | common |  | PlatformTransactionManager | To use the PlatformTransactionManager for managing transactions.
| joinTransaction | common | true | boolean | The camel-jpa component will join transaction by default. 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 JpaComponent instead of having to set it on all endpoints.
| sharedEntityManager | common | false | boolean | Whether to use Spring's SharedEntityManager for the consumer/producer. Note in most cases joinTransaction should be set to false as this is not an EXTENDED EntityManager.
| resolvePropertyPlaceholders | advanced | true | boolean | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders.
|=======================================================================
// component options: END








// endpoint options: START
The JPA endpoint is configured using URI syntax:

    jpa:entityType

with the following path and query parameters:

#### Path Parameters (1 parameters):

[width="100%",cols="2,1,1m,6",options="header"]
|=======================================================================
| Name | Default | Java Type | Description
| entityType |  | Class<?> | *Required* The JPA annotated class to use as entity.
|=======================================================================

#### Query Parameters (42 parameters):

[width="100%",cols="2,1,1m,1m,5",options="header"]
|=======================================================================
| Name | Group | Default | Java Type | Description
| joinTransaction | common | true | boolean | The camel-jpa component will join transaction by default. 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 JpaComponent instead of having to set it on all endpoints.
| maximumResults | common | -1 | int | Set the maximum number of results to retrieve on the Query.
| namedQuery | common |  | String | To use a named query.
| nativeQuery | common |  | String | To use a custom native query. You may want to use the option resultClass also when using native queries.
| parameters | common |  | Map | This key/value mapping is used for building the query parameters. It is expected to be of the generic type java.util.Map 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. When it's used for producer Simple expression can be used as a parameter value. It allows you to retrieve parameter values from the message body header and etc.
| persistenceUnit | common | camel | String | *Required* The JPA persistence unit used by default.
| query | common |  | String | To use a custom query.
| resultClass | common |  | Class<?> | Defines the type of the returned payload (we will call entityManager.createNativeQuery(nativeQuery resultClass) instead of entityManager.createNativeQuery(nativeQuery)). Without this option we will return an object array. Only has an affect when using in conjunction with native query when consuming data.
{'fraction_non_alphanumeric': 0.1330909090909091, 'fraction_numerical': 0.005752066115702479, 'mean_word_length': 4.235721703011422, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4503436', 'n_tokens_mistral': 3811, 'n_tokens_neox': 3594, 'n_words': 1907}