This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 703dacb04e23 CAMEL-27893: camel-sql - endpoint usePlaceholder, 
consumer maxRows, outputHeader, StreamList generated keys, sql-stored batch 
expressions (#31304)
703dacb04e23 is described below

commit 703dacb04e238b8c52e27f6640eea99dfc815e53
Author: Adriano Machado <[email protected]>
AuthorDate: Thu Dec 3 15:27:09 2026 -0500

    CAMEL-27893: camel-sql - endpoint usePlaceholder, consumer maxRows, 
outputHeader, StreamList generated keys, sql-stored batch expressions (#31304)
    
    * CAMEL-27893: camel-sql - endpoint usePlaceholder, consumer maxRows, 
outputHeader, StreamList generated keys, sql-stored batch expressions
    * CAMEL-27893: Escape Simple expressions in sql-stored docs
    * CAMEL-27893: camel-sql - restore template.maxRows when maxMessagesPerPoll 
is reset to 0
    * CAMEL-27893: camel-sql - copy the exchange per sql-stored batch item only 
for simple expressions, share the generated keys code
    
    Co-authored-by: Claude <[email protected]>
    Co-authored-by: Claude Opus 5.5 <[email protected]>
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 .../org/apache/camel/catalog/components/sql.json   |  8 +-
 .../apache/camel/catalog/docs/sql-component.adoc   |  4 +-
 .../camel/catalog/docs/sql-stored-component.adoc   |  3 +
 .../org/apache/camel/component/sql/sql.json        |  8 +-
 .../camel-sql/src/main/docs/sql-component.adoc     |  4 +-
 .../src/main/docs/sql-stored-component.adoc        |  3 +
 .../camel/component/sql/DefaultSqlEndpoint.java    | 12 +--
 .../apache/camel/component/sql/SqlComponent.java   | 29 ++++---
 .../apache/camel/component/sql/SqlConstants.java   |  3 +-
 .../apache/camel/component/sql/SqlConsumer.java    |  7 +-
 .../apache/camel/component/sql/SqlProducer.java    | 37 ++++++---
 .../sql/stored/CallableStatementWrapper.java       | 20 ++++-
 .../sql/stored/template/ast/InParameter.java       |  9 ++
 .../sql/SqlComponentUsePlaceholderTest.java        | 86 ++++++++++++++++++++
 .../sql/SqlConsumerTemplateMaxRowsTest.java        | 95 ++++++++++++++++++++++
 .../camel/component/sql/SqlGeneratedKeysTest.java  | 22 +++++
 .../component/sql/SqlProducerOutputHeaderTest.java | 26 ++++++
 .../sql/stored/CallableStatementWrapperTest.java   | 21 +++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_25.adoc    | 22 +++++
 .../component/dsl/SqlComponentBuilderFactory.java  |  4 +-
 .../endpoint/dsl/SqlEndpointBuilderFactory.java    | 67 +++++++--------
 21 files changed, 409 insertions(+), 81 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sql.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sql.json
index 1be85c694f0f..57f690ddb58a 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sql.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/sql.json
@@ -32,7 +32,7 @@
     "fetchSize": { "index": 5, "kind": "property", "displayName": "Fetch 
Size", "group": "advanced", "label": "advanced", "required": false, "type": 
"integer", "javaType": "int", "deprecated": false, "autowired": false, 
"secret": false, "description": "The number of rows that the JDBC driver 
fetches from the database at a time when more rows are needed 
(Statement.setFetchSize), for the endpoints that do not set their own. It is a 
hint that the driver may ignore: a higher value reads a la [...]
     "rowMapperFactory": { "index": 6, "kind": "property", "displayName": "Row 
Mapper Factory", "group": "advanced", "label": "advanced", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.sql.RowMapperFactory", "deprecated": false, 
"autowired": true, "secret": false, "description": "A custom RowMapperFactory 
that creates the Spring RowMapper of the rows, for the endpoints that do not 
set their own. By default, a ColumnMapRowMapper (a Map of the column names and  
[...]
     "serviceLocationEnabled": { "index": 7, "kind": "property", "displayName": 
"Service Location Enabled", "group": "advanced", "label": "advanced", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "Whether to detect the network address location of the Database 
on startup. This information is gathered via reflection on the DataSource, and 
is vendor specific. This option can be used  [...]
-    "usePlaceholder": { "index": 8, "kind": "property", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder of the endpoints (the placeholder option, # by default) 
with ? in their queries: the query and the onConsume, onConsumeFailed and 
onConsumeBatchComplete queries." },
+    "usePlaceholder": { "index": 8, "kind": "property", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder of the endpoints (the placeholder option, # by default) 
with ? in their queries: the query and the onConsume, onConsumeFailed and 
onConsumeBatchComplete queries. This i [...]
     "healthCheckConsumerEnabled": { "index": 9, "kind": "property", 
"displayName": "Health Check Consumer Enabled", "group": "health", "label": 
"health", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "Used for enabling or disabling all consumer based health checks 
from this component" },
     "healthCheckProducerEnabled": { "index": 10, "kind": "property", 
"displayName": "Health Check Producer Enabled", "group": "health", "label": 
"health", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "Used for enabling or disabling all producer based health checks 
from this component. Notice: Camel has by default disabled all producer based 
health-checks. You can turn on produce [...]
     "allowQueryFromHeader": { "index": 11, "kind": "property", "displayName": 
"Allow Query From Header", "group": "security", "label": "producer,security", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "security": "insecure:dev", 
"insecureValue": "true", "defaultValue": false, "description": "Whether to 
allow overriding the endpoint-configured SQL query with the CamelSqlQuery 
header. Disabled by default; enable it o [...]
@@ -41,7 +41,7 @@
     "CamelSqlQuery": { "index": 0, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The query to run instead of the query of the endpoint. This 
header is ignored unless the endpoint enables allowQueryFromHeader=true 
(disabled by default). The placeholder is replaced with ? as in the query of 
the endpoint (usePlaceholder), so a parameter can be w [...]
     "CamelSqlUpdateCount": { "index": 1, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"important": true, "description": "The number of rows updated by a query that 
is not a select, as an Integer (Statement.getUpdateCount). With batch=true, the 
sum of the update counts of the batch items; an item the JDBC driver returns no 
count for (Statement.SUCCESS_NO_IN [...]
     "CamelSqlRowCount": { "index": 2, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"important": true, "description": "The number of rows returned for select 
operations, returned as an Integer object. This header is not provided when 
using outputType=StreamList.", "constantName": 
"org.apache.camel.component.sql.SqlConstants#SQL_ROW_COUNT" },
-    "CamelSqlRetrieveGeneratedKeys": { "index": 3, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": "false", "description": "Whether to retrieve the keys 
that the database generates for an insert (Statement.RETURN_GENERATED_KEYS) 
into the CamelSqlGeneratedKeyRows and CamelSqlGeneratedKeysRowCount headers. 
Not supported with outputType=StreamLis [...]
+    "CamelSqlRetrieveGeneratedKeys": { "index": 3, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": "false", "description": "Whether to retrieve the keys 
that the database generates for an insert (Statement.RETURN_GENERATED_KEYS) 
into the CamelSqlGeneratedKeyRows and CamelSqlGeneratedKeysRowCount headers.", 
"constantName": "org.apache.camel.com [...]
     "CamelSqlGeneratedColumns": { "index": 4, "kind": "header", "displayName": 
"", "group": "producer", "label": "producer", "required": false, "javaType": 
"String[] or int[]", "deprecated": false, "autowired": false, "secret": false, 
"description": "The columns of the generated keys to retrieve: a String[] of 
column names or an int[] of column indexes, passed to 
Connection.prepareStatement. Only used with CamelSqlRetrieveGeneratedKeys=true; 
some databases, such as Oracle, need it.", "co [...]
     "CamelSqlGeneratedKeysRowCount": { "index": 5, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Integer", "deprecated": false, "autowired": false, "secret": 
false, "description": "The number of rows of generated keys in the 
CamelSqlGeneratedKeyRows header.", "constantName": 
"org.apache.camel.component.sql.SqlConstants#SQL_GENERATED_KEYS_ROW_COUNT" },
     "CamelSqlGeneratedKeyRows": { "index": 6, "kind": "header", "displayName": 
"", "group": "producer", "label": "producer", "required": false, "javaType": 
"List<Map<String, Object>>", "deprecated": false, "autowired": false, "secret": 
false, "description": "The generated keys: a List with a Map of the column 
names and their values for each generated row; an empty List for a select.", 
"constantName": 
"org.apache.camel.component.sql.SqlConstants#SQL_GENERATED_KEYS_DATA" },
@@ -63,7 +63,7 @@
     "separator": { "index": 6, "kind": "parameter", "displayName": 
"Separator", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "char", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": ",", "description": "The character that splits 
a String message body into the values of the positional parameters, when the 
query has more than one of them; quoted values are kept together. Named 
parameters do not use it, and the values of an IN lis [...]
     "breakBatchOnConsumeFail": { "index": 7, "kind": "parameter", 
"displayName": "Break Batch On Consume Fail", "group": "consumer", "label": 
"consumer", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
false, "description": "Whether a failure of the onConsume, onConsumeFailed or 
onConsumeBatchComplete query (or an unexpected update count) ends the poll: the 
remaining rows are not routed and the poll fa [...]
     "expectedUpdateCount": { "index": 8, "kind": "parameter", "displayName": 
"Expected Update Count", "group": "consumer", "label": "consumer", "required": 
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": -1, "description": "The update count 
that the onConsume or onConsumeFailed query must return; another count fails 
the query with an SQLException, handled as breakBatchOnConsumeFail says. -1 
(the default) does not chec [...]
-    "maxMessagesPerPoll": { "index": 9, "kind": "parameter", "displayName": 
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required": 
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": 
false, "secret": false, "description": "The maximum number of rows that a poll 
reads. It is set as the maxRows of the JdbcTemplate (Statement.setMaxRows), so 
the database returns at most this many rows, and it replaces template.maxRows. 
0 (the default) means [...]
+    "maxMessagesPerPoll": { "index": 9, "kind": "parameter", "displayName": 
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required": 
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": 
false, "secret": false, "description": "The maximum number of rows that a poll 
reads. When set, it is set as the maxRows of the JdbcTemplate 
(Statement.setMaxRows), so the database returns at most this many rows, and it 
replaces template.maxRows. 0 (the defa [...]
     "onConsume": { "index": 10, "kind": "parameter", "displayName": "On 
Consume", "group": "consumer", "label": "consumer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "description": "A query to run after the exchange of a 
row was processed successfully, for example to mark the row as processed. Its 
named parameters take their values from the columns of the row, then from the 
headers and variables of the e [...]
     "onConsumeBatchComplete": { "index": 11, "kind": "parameter", 
"displayName": "On Consume Batch Complete", "group": "consumer", "label": 
"consumer", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "A query to run once after all the rows of a poll were 
processed, for example to update them in bulk. The query cannot have 
parameters. It does not run when the poll ended before all the rows were r [...]
     "onConsumeFailed": { "index": 12, "kind": "parameter", "displayName": "On 
Consume Failed", "group": "consumer", "label": "consumer", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "A query to run after the 
exchange of a row failed or was marked rollback only, for example to mark the 
row as failed. Its named parameters take their values from the columns of the 
row, then from the headers and  [...]
@@ -88,7 +88,7 @@
     "prepareStatementStrategy": { "index": 31, "kind": "parameter", 
"displayName": "Prepare Statement Strategy", "group": "advanced", "label": 
"advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.component.sql.SqlPrepareStatementStrategy", "deprecated": 
false, "autowired": false, "secret": false, "description": "A custom 
org.apache.camel.component.sql.SqlPrepareStatementStrategy that prepares the 
query (its named parameters) and sets the parameter values on the  [...]
     "rowMapperFactory": { "index": 32, "kind": "parameter", "displayName": 
"Row Mapper Factory", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.component.sql.RowMapperFactory", "deprecated": false, 
"autowired": false, "secret": false, "description": "A custom RowMapperFactory 
that creates the Spring RowMapper of the rows. By default, a ColumnMapRowMapper 
(a Map of the column names and their values), or a BeanPropertyRowMapper  [...]
     "templateOptions": { "index": 33, "kind": "parameter", "displayName": 
"Template Options", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map<java.lang.String, 
java.lang.Object>", "prefix": "template.", "multiValue": true, "deprecated": 
false, "autowired": false, "secret": false, "description": "Properties of the 
Spring JdbcTemplate that runs the queries, such as template.maxRows, 
template.queryTimeout (in seconds) and template.fe [...]
-    "usePlaceholder": { "index": 34, "kind": "parameter", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder with ? in a query loaded from a resource (file: or 
classpath:) and in the CamelSqlQuery header. The query in the URI and the 
onConsume queries follow the usePlacehold [...]
+    "usePlaceholder": { "index": 34, "kind": "parameter", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder with ? in the queries: the query of the endpoint (also 
when it is loaded from a resource, such as file: or classpath:), the onConsume, 
onConsumeFailed and onConsumeBa [...]
     "backoffErrorThreshold": { "index": 35, "kind": "parameter", 
"displayName": "Backoff Error Threshold", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
number of subsequent error polls (failed due some error) that should happen 
before the backoffMultipler should kick-in." },
     "backoffIdleThreshold": { "index": 36, "kind": "parameter", "displayName": 
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "The number of subsequent 
idle polls that should happen before the backoffMultipler should kick-in." },
     "backoffMultiplier": { "index": 37, "kind": "parameter", "displayName": 
"Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "To let the scheduled 
polling consumer backoff if there has been a number of subsequent idles\/errors 
in a row. The multiplier is then the number of polls that will be skipped 
before the next actual attempt is h [...]
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
index 563ad90863e1..520182baa0a2 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-component.adoc
@@ -161,7 +161,8 @@ 
http://static.springframework.org/spring/docs/6.0.x/api/org/springframework/jdbc
 method. For `update` operations, the message body is not changed, and the 
number of updated rows is in the `CamelSqlUpdateCount` header.
 
 By default, the result is placed in the message body.  If the
-outputHeader parameter is set, the result is placed in the header.  This
+outputHeader parameter is set, the result is placed in the header (for an 
`update`
+or a batch there is no result, so the header is not set).  This
 is an alternative to using a full message enrichment pattern to add
 headers, it provides a concise syntax for querying a sequence or some
 other small value into a header.  It is convenient to use outputHeader
@@ -297,6 +298,7 @@ If you insert data using SQL INSERT, then the RDBMS may 
support auto
 generated keys. You can instruct the SQL producer to return the
 generated keys in headers. To do that set the header 
`CamelSqlRetrieveGeneratedKeys=true`.
 Then the generated keys will be provided as headers with the keys listed in 
the table above.
+This works with `outputType=StreamList` too.
 
 To specify which generated columns should be retrieved, set the header 
`CamelSqlGeneratedColumns`
 to a `String[]` or `int[]`, indicating the column names or indexes, 
respectively. Some databases
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-stored-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-stored-component.adoc
index fe753dd789df..4f1d02ea6988 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-stored-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/sql-stored-component.adoc
@@ -229,6 +229,9 @@ The batch items are taken from the message body (or from 
the `CamelSqlStoredPara
 * a `List` or an `Iterator`, where each element is one batch item, typically a 
`Map` with the values of the IN parameters.
 * a single `Map`, which is one batch item.
 
+The parameters are evaluated for each batch item: `:#name` reads `name` from 
the item, and a simple expression
+such as `+${body}+` is evaluated with the batch item as the message body.
+
 ._XML-only: stored procedure call in batch mode_
 [source,xml]
 ----
diff --git 
a/components/camel-sql/src/generated/resources/META-INF/org/apache/camel/component/sql/sql.json
 
b/components/camel-sql/src/generated/resources/META-INF/org/apache/camel/component/sql/sql.json
index 1be85c694f0f..57f690ddb58a 100644
--- 
a/components/camel-sql/src/generated/resources/META-INF/org/apache/camel/component/sql/sql.json
+++ 
b/components/camel-sql/src/generated/resources/META-INF/org/apache/camel/component/sql/sql.json
@@ -32,7 +32,7 @@
     "fetchSize": { "index": 5, "kind": "property", "displayName": "Fetch 
Size", "group": "advanced", "label": "advanced", "required": false, "type": 
"integer", "javaType": "int", "deprecated": false, "autowired": false, 
"secret": false, "description": "The number of rows that the JDBC driver 
fetches from the database at a time when more rows are needed 
(Statement.setFetchSize), for the endpoints that do not set their own. It is a 
hint that the driver may ignore: a higher value reads a la [...]
     "rowMapperFactory": { "index": 6, "kind": "property", "displayName": "Row 
Mapper Factory", "group": "advanced", "label": "advanced", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.sql.RowMapperFactory", "deprecated": false, 
"autowired": true, "secret": false, "description": "A custom RowMapperFactory 
that creates the Spring RowMapper of the rows, for the endpoints that do not 
set their own. By default, a ColumnMapRowMapper (a Map of the column names and  
[...]
     "serviceLocationEnabled": { "index": 7, "kind": "property", "displayName": 
"Service Location Enabled", "group": "advanced", "label": "advanced", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "Whether to detect the network address location of the Database 
on startup. This information is gathered via reflection on the DataSource, and 
is vendor specific. This option can be used  [...]
-    "usePlaceholder": { "index": 8, "kind": "property", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder of the endpoints (the placeholder option, # by default) 
with ? in their queries: the query and the onConsume, onConsumeFailed and 
onConsumeBatchComplete queries." },
+    "usePlaceholder": { "index": 8, "kind": "property", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder of the endpoints (the placeholder option, # by default) 
with ? in their queries: the query and the onConsume, onConsumeFailed and 
onConsumeBatchComplete queries. This i [...]
     "healthCheckConsumerEnabled": { "index": 9, "kind": "property", 
"displayName": "Health Check Consumer Enabled", "group": "health", "label": 
"health", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "Used for enabling or disabling all consumer based health checks 
from this component" },
     "healthCheckProducerEnabled": { "index": 10, "kind": "property", 
"displayName": "Health Check Producer Enabled", "group": "health", "label": 
"health", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true, 
"description": "Used for enabling or disabling all producer based health checks 
from this component. Notice: Camel has by default disabled all producer based 
health-checks. You can turn on produce [...]
     "allowQueryFromHeader": { "index": 11, "kind": "property", "displayName": 
"Allow Query From Header", "group": "security", "label": "producer,security", 
"required": false, "type": "boolean", "javaType": "boolean", "deprecated": 
false, "autowired": false, "secret": false, "security": "insecure:dev", 
"insecureValue": "true", "defaultValue": false, "description": "Whether to 
allow overriding the endpoint-configured SQL query with the CamelSqlQuery 
header. Disabled by default; enable it o [...]
@@ -41,7 +41,7 @@
     "CamelSqlQuery": { "index": 0, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The query to run instead of the query of the endpoint. This 
header is ignored unless the endpoint enables allowQueryFromHeader=true 
(disabled by default). The placeholder is replaced with ? as in the query of 
the endpoint (usePlaceholder), so a parameter can be w [...]
     "CamelSqlUpdateCount": { "index": 1, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"important": true, "description": "The number of rows updated by a query that 
is not a select, as an Integer (Statement.getUpdateCount). With batch=true, the 
sum of the update counts of the batch items; an item the JDBC driver returns no 
count for (Statement.SUCCESS_NO_IN [...]
     "CamelSqlRowCount": { "index": 2, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"Integer", "deprecated": false, "autowired": false, "secret": false, 
"important": true, "description": "The number of rows returned for select 
operations, returned as an Integer object. This header is not provided when 
using outputType=StreamList.", "constantName": 
"org.apache.camel.component.sql.SqlConstants#SQL_ROW_COUNT" },
-    "CamelSqlRetrieveGeneratedKeys": { "index": 3, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": "false", "description": "Whether to retrieve the keys 
that the database generates for an insert (Statement.RETURN_GENERATED_KEYS) 
into the CamelSqlGeneratedKeyRows and CamelSqlGeneratedKeysRowCount headers. 
Not supported with outputType=StreamLis [...]
+    "CamelSqlRetrieveGeneratedKeys": { "index": 3, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": "false", "description": "Whether to retrieve the keys 
that the database generates for an insert (Statement.RETURN_GENERATED_KEYS) 
into the CamelSqlGeneratedKeyRows and CamelSqlGeneratedKeysRowCount headers.", 
"constantName": "org.apache.camel.com [...]
     "CamelSqlGeneratedColumns": { "index": 4, "kind": "header", "displayName": 
"", "group": "producer", "label": "producer", "required": false, "javaType": 
"String[] or int[]", "deprecated": false, "autowired": false, "secret": false, 
"description": "The columns of the generated keys to retrieve: a String[] of 
column names or an int[] of column indexes, passed to 
Connection.prepareStatement. Only used with CamelSqlRetrieveGeneratedKeys=true; 
some databases, such as Oracle, need it.", "co [...]
     "CamelSqlGeneratedKeysRowCount": { "index": 5, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "Integer", "deprecated": false, "autowired": false, "secret": 
false, "description": "The number of rows of generated keys in the 
CamelSqlGeneratedKeyRows header.", "constantName": 
"org.apache.camel.component.sql.SqlConstants#SQL_GENERATED_KEYS_ROW_COUNT" },
     "CamelSqlGeneratedKeyRows": { "index": 6, "kind": "header", "displayName": 
"", "group": "producer", "label": "producer", "required": false, "javaType": 
"List<Map<String, Object>>", "deprecated": false, "autowired": false, "secret": 
false, "description": "The generated keys: a List with a Map of the column 
names and their values for each generated row; an empty List for a select.", 
"constantName": 
"org.apache.camel.component.sql.SqlConstants#SQL_GENERATED_KEYS_DATA" },
@@ -63,7 +63,7 @@
     "separator": { "index": 6, "kind": "parameter", "displayName": 
"Separator", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "char", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": ",", "description": "The character that splits 
a String message body into the values of the positional parameters, when the 
query has more than one of them; quoted values are kept together. Named 
parameters do not use it, and the values of an IN lis [...]
     "breakBatchOnConsumeFail": { "index": 7, "kind": "parameter", 
"displayName": "Break Batch On Consume Fail", "group": "consumer", "label": 
"consumer", "required": false, "type": "boolean", "javaType": "boolean", 
"deprecated": false, "autowired": false, "secret": false, "defaultValue": 
false, "description": "Whether a failure of the onConsume, onConsumeFailed or 
onConsumeBatchComplete query (or an unexpected update count) ends the poll: the 
remaining rows are not routed and the poll fa [...]
     "expectedUpdateCount": { "index": 8, "kind": "parameter", "displayName": 
"Expected Update Count", "group": "consumer", "label": "consumer", "required": 
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": -1, "description": "The update count 
that the onConsume or onConsumeFailed query must return; another count fails 
the query with an SQLException, handled as breakBatchOnConsumeFail says. -1 
(the default) does not chec [...]
-    "maxMessagesPerPoll": { "index": 9, "kind": "parameter", "displayName": 
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required": 
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": 
false, "secret": false, "description": "The maximum number of rows that a poll 
reads. It is set as the maxRows of the JdbcTemplate (Statement.setMaxRows), so 
the database returns at most this many rows, and it replaces template.maxRows. 
0 (the default) means [...]
+    "maxMessagesPerPoll": { "index": 9, "kind": "parameter", "displayName": 
"Max Messages Per Poll", "group": "consumer", "label": "consumer", "required": 
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": 
false, "secret": false, "description": "The maximum number of rows that a poll 
reads. When set, it is set as the maxRows of the JdbcTemplate 
(Statement.setMaxRows), so the database returns at most this many rows, and it 
replaces template.maxRows. 0 (the defa [...]
     "onConsume": { "index": 10, "kind": "parameter", "displayName": "On 
Consume", "group": "consumer", "label": "consumer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "description": "A query to run after the exchange of a 
row was processed successfully, for example to mark the row as processed. Its 
named parameters take their values from the columns of the row, then from the 
headers and variables of the e [...]
     "onConsumeBatchComplete": { "index": 11, "kind": "parameter", 
"displayName": "On Consume Batch Complete", "group": "consumer", "label": 
"consumer", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "A query to run once after all the rows of a poll were 
processed, for example to update them in bulk. The query cannot have 
parameters. It does not run when the poll ended before all the rows were r [...]
     "onConsumeFailed": { "index": 12, "kind": "parameter", "displayName": "On 
Consume Failed", "group": "consumer", "label": "consumer", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "A query to run after the 
exchange of a row failed or was marked rollback only, for example to mark the 
row as failed. Its named parameters take their values from the columns of the 
row, then from the headers and  [...]
@@ -88,7 +88,7 @@
     "prepareStatementStrategy": { "index": 31, "kind": "parameter", 
"displayName": "Prepare Statement Strategy", "group": "advanced", "label": 
"advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.component.sql.SqlPrepareStatementStrategy", "deprecated": 
false, "autowired": false, "secret": false, "description": "A custom 
org.apache.camel.component.sql.SqlPrepareStatementStrategy that prepares the 
query (its named parameters) and sets the parameter values on the  [...]
     "rowMapperFactory": { "index": 32, "kind": "parameter", "displayName": 
"Row Mapper Factory", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": 
"org.apache.camel.component.sql.RowMapperFactory", "deprecated": false, 
"autowired": false, "secret": false, "description": "A custom RowMapperFactory 
that creates the Spring RowMapper of the rows. By default, a ColumnMapRowMapper 
(a Map of the column names and their values), or a BeanPropertyRowMapper  [...]
     "templateOptions": { "index": 33, "kind": "parameter", "displayName": 
"Template Options", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map<java.lang.String, 
java.lang.Object>", "prefix": "template.", "multiValue": true, "deprecated": 
false, "autowired": false, "secret": false, "description": "Properties of the 
Spring JdbcTemplate that runs the queries, such as template.maxRows, 
template.queryTimeout (in seconds) and template.fe [...]
-    "usePlaceholder": { "index": 34, "kind": "parameter", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder with ? in a query loaded from a resource (file: or 
classpath:) and in the CamelSqlQuery header. The query in the URI and the 
onConsume queries follow the usePlacehold [...]
+    "usePlaceholder": { "index": 34, "kind": "parameter", "displayName": "Use 
Placeholder", "group": "advanced", "label": "advanced", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": true, "description": "Whether to 
replace the placeholder with ? in the queries: the query of the endpoint (also 
when it is loaded from a resource, such as file: or classpath:), the onConsume, 
onConsumeFailed and onConsumeBa [...]
     "backoffErrorThreshold": { "index": 35, "kind": "parameter", 
"displayName": "Backoff Error Threshold", "group": "scheduler", "label": 
"consumer,scheduler", "required": false, "type": "integer", "javaType": "int", 
"deprecated": false, "autowired": false, "secret": false, "description": "The 
number of subsequent error polls (failed due some error) that should happen 
before the backoffMultipler should kick-in." },
     "backoffIdleThreshold": { "index": 36, "kind": "parameter", "displayName": 
"Backoff Idle Threshold", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "The number of subsequent 
idle polls that should happen before the backoffMultipler should kick-in." },
     "backoffMultiplier": { "index": 37, "kind": "parameter", "displayName": 
"Backoff Multiplier", "group": "scheduler", "label": "consumer,scheduler", 
"required": false, "type": "integer", "javaType": "int", "deprecated": false, 
"autowired": false, "secret": false, "description": "To let the scheduled 
polling consumer backoff if there has been a number of subsequent idles\/errors 
in a row. The multiplier is then the number of polls that will be skipped 
before the next actual attempt is h [...]
diff --git a/components/camel-sql/src/main/docs/sql-component.adoc 
b/components/camel-sql/src/main/docs/sql-component.adoc
index 563ad90863e1..520182baa0a2 100644
--- a/components/camel-sql/src/main/docs/sql-component.adoc
+++ b/components/camel-sql/src/main/docs/sql-component.adoc
@@ -161,7 +161,8 @@ 
http://static.springframework.org/spring/docs/6.0.x/api/org/springframework/jdbc
 method. For `update` operations, the message body is not changed, and the 
number of updated rows is in the `CamelSqlUpdateCount` header.
 
 By default, the result is placed in the message body.  If the
-outputHeader parameter is set, the result is placed in the header.  This
+outputHeader parameter is set, the result is placed in the header (for an 
`update`
+or a batch there is no result, so the header is not set).  This
 is an alternative to using a full message enrichment pattern to add
 headers, it provides a concise syntax for querying a sequence or some
 other small value into a header.  It is convenient to use outputHeader
@@ -297,6 +298,7 @@ If you insert data using SQL INSERT, then the RDBMS may 
support auto
 generated keys. You can instruct the SQL producer to return the
 generated keys in headers. To do that set the header 
`CamelSqlRetrieveGeneratedKeys=true`.
 Then the generated keys will be provided as headers with the keys listed in 
the table above.
+This works with `outputType=StreamList` too.
 
 To specify which generated columns should be retrieved, set the header 
`CamelSqlGeneratedColumns`
 to a `String[]` or `int[]`, indicating the column names or indexes, 
respectively. Some databases
diff --git a/components/camel-sql/src/main/docs/sql-stored-component.adoc 
b/components/camel-sql/src/main/docs/sql-stored-component.adoc
index fe753dd789df..4f1d02ea6988 100644
--- a/components/camel-sql/src/main/docs/sql-stored-component.adoc
+++ b/components/camel-sql/src/main/docs/sql-stored-component.adoc
@@ -229,6 +229,9 @@ The batch items are taken from the message body (or from 
the `CamelSqlStoredPara
 * a `List` or an `Iterator`, where each element is one batch item, typically a 
`Map` with the values of the IN parameters.
 * a single `Map`, which is one batch item.
 
+The parameters are evaluated for each batch item: `:#name` reads `name` from 
the item, and a simple expression
+such as `+${body}+` is evaluated with the batch item as the message body.
+
 ._XML-only: stored procedure call in batch mode_
 [source,xml]
 ----
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
index cefcc38bd54f..cf9a13914701 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/DefaultSqlEndpoint.java
@@ -67,9 +67,9 @@ public abstract class DefaultSqlEndpoint extends 
DefaultPollingEndpoint implemen
                             + " the sum of the update counts.")
     private boolean batch;
     @UriParam(label = "consumer",
-              description = "The maximum number of rows that a poll reads. It 
is set as the maxRows of the JdbcTemplate"
-                            + " (Statement.setMaxRows), so the database 
returns at most this many rows, and it replaces"
-                            + " template.maxRows. 0 (the default) means no 
limit.")
+              description = "The maximum number of rows that a poll reads. 
When set, it is set as the maxRows of the"
+                            + " JdbcTemplate (Statement.setMaxRows), so the 
database returns at most this many rows, and it"
+                            + " replaces template.maxRows. 0 (the default) 
means no limit, other than template.maxRows.")
     private int maxMessagesPerPoll;
     @UriParam(label = "consumer,advanced",
               description = "A custom 
org.apache.camel.component.sql.SqlProcessingStrategy that runs the onConsume,"
@@ -178,9 +178,9 @@ public abstract class DefaultSqlEndpoint extends 
DefaultPollingEndpoint implemen
                             + " replaced inside quoted strings.")
     private String placeholder = "#";
     @UriParam(label = "advanced", defaultValue = "true",
-              description = "Whether to replace the placeholder with ? in a 
query loaded from a resource (file: or"
-                            + " classpath:) and in the CamelSqlQuery header. 
The query in the URI and the onConsume queries"
-                            + " follow the usePlaceholder option of the 
component.")
+              description = "Whether to replace the placeholder with ? in the 
queries: the query of the endpoint (also"
+                            + " when it is loaded from a resource, such as 
file: or classpath:), the onConsume,"
+                            + " onConsumeFailed and onConsumeBatchComplete 
queries, and the CamelSqlQuery header.")
     private boolean usePlaceholder = true;
     @UriParam(label = "advanced", prefix = "template.", multiValue = true,
               description = "Properties of the Spring JdbcTemplate that runs 
the queries, such as template.maxRows,"
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
index b8e8ec631a7f..39030862e3c2 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlComponent.java
@@ -45,7 +45,7 @@ public class SqlComponent extends HealthCheckComponent 
implements SecretRotation
     @Metadata(label = "advanced", defaultValue = "true",
               description = "Whether to replace the placeholder of the 
endpoints (the placeholder option, # by default) with ?"
                             + " in their queries: the query and the onConsume, 
onConsumeFailed and onConsumeBatchComplete"
-                            + " queries.")
+                            + " queries. This is the default for all sql 
endpoints and can be overridden per endpoint.")
     private boolean usePlaceholder = true;
     @Metadata(label = "advanced", autowired = true,
               description = "A custom RowMapperFactory that creates the Spring 
RowMapper of the rows, for the endpoints that"
@@ -101,30 +101,18 @@ public class SqlComponent extends HealthCheckComponent 
implements SecretRotation
             throw new IllegalArgumentException("Query parameter is required");
         }
         String parameterPlaceholderSubstitute = 
getAndRemoveParameter(parameters, "placeholder", String.class, "#");
-        if (usePlaceholder) {
-            query = query.replaceAll(parameterPlaceholderSubstitute, "?");
-        }
         String onConsume = getAndRemoveParameter(parameters, 
"consumer.onConsume", String.class);
         if (onConsume == null) {
             onConsume = getAndRemoveParameter(parameters, "onConsume", 
String.class);
         }
-        if (onConsume != null && usePlaceholder) {
-            onConsume = onConsume.replaceAll(parameterPlaceholderSubstitute, 
"?");
-        }
         String onConsumeFailed = getAndRemoveParameter(parameters, 
"consumer.onConsumeFailed", String.class);
         if (onConsumeFailed == null) {
             onConsumeFailed = getAndRemoveParameter(parameters, 
"onConsumeFailed", String.class);
         }
-        if (onConsumeFailed != null && usePlaceholder) {
-            onConsumeFailed = 
onConsumeFailed.replaceAll(parameterPlaceholderSubstitute, "?");
-        }
         String onConsumeBatchComplete = getAndRemoveParameter(parameters, 
"consumer.onConsumeBatchComplete", String.class);
         if (onConsumeBatchComplete == null) {
             onConsumeBatchComplete = getAndRemoveParameter(parameters, 
"onConsumeBatchComplete", String.class);
         }
-        if (onConsumeBatchComplete != null && usePlaceholder) {
-            onConsumeBatchComplete = 
onConsumeBatchComplete.replaceAll(parameterPlaceholderSubstitute, "?");
-        }
         RowMapperFactory factory
                 = getAndRemoveOrResolveReferenceParameter(parameters, 
"rowMapperFactory", RowMapperFactory.class);
         if (factory == null) {
@@ -146,6 +134,21 @@ public class SqlComponent extends HealthCheckComponent 
implements SecretRotation
         endpoint.setRowMapperFactory(factory);
         setProperties(endpoint, parameters);
 
+        // replace the placeholder after setProperties, so the usePlaceholder 
option of the endpoint applies
+        if (endpoint.isUsePlaceholder()) {
+            String placeholder = endpoint.getPlaceholder();
+            endpoint.setQuery(endpoint.getQuery().replaceAll(placeholder, 
"?"));
+            if (endpoint.getOnConsume() != null) {
+                
endpoint.setOnConsume(endpoint.getOnConsume().replaceAll(placeholder, "?"));
+            }
+            if (endpoint.getOnConsumeFailed() != null) {
+                
endpoint.setOnConsumeFailed(endpoint.getOnConsumeFailed().replaceAll(placeholder,
 "?"));
+            }
+            if (endpoint.getOnConsumeBatchComplete() != null) {
+                
endpoint.setOnConsumeBatchComplete(endpoint.getOnConsumeBatchComplete().replaceAll(placeholder,
 "?"));
+            }
+        }
+
         // endpoint configured data source takes precedence
         DataSource ds = dataSource;
         if (endpoint.getDataSource() != null) {
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
index 58abb6c7f7f2..63afd21da2cf 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConstants.java
@@ -48,8 +48,7 @@ public final class SqlConstants {
      */
     @Metadata(label = "producer", description = "Whether to retrieve the keys 
that the database generates for an insert" +
                                                 " 
(Statement.RETURN_GENERATED_KEYS) into the CamelSqlGeneratedKeyRows and" +
-                                                " 
CamelSqlGeneratedKeysRowCount headers. Not supported with" +
-                                                " outputType=StreamList.",
+                                                " 
CamelSqlGeneratedKeysRowCount headers.",
               javaType = "Boolean",
               defaultValue = "false")
     public static final String SQL_RETRIEVE_GENERATED_KEYS = 
"CamelSqlRetrieveGeneratedKeys";
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConsumer.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConsumer.java
index 445155eeb531..d9c2272550f0 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConsumer.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlConsumer.java
@@ -51,6 +51,8 @@ public class SqlConsumer extends 
ScheduledBatchPollingConsumer {
     private final String query;
     private String resolvedQuery;
     private final JdbcTemplate jdbcTemplate;
+    // the maxRows of the template (template.maxRows), restored when 
maxMessagesPerPoll is set back to 0
+    private final int templateMaxRows;
     private final NamedParameterJdbcTemplate namedJdbcTemplate;
     private final SqlParameterSource parameterSource;
     private final SqlPrepareStatementStrategy sqlPrepareStatementStrategy;
@@ -79,6 +81,7 @@ public class SqlConsumer extends 
ScheduledBatchPollingConsumer {
                        SqlProcessingStrategy sqlProcessingStrategy) {
         super(endpoint, processor);
         this.jdbcTemplate = jdbcTemplate;
+        this.templateMaxRows = jdbcTemplate != null ? 
jdbcTemplate.getMaxRows() : -1;
         this.namedJdbcTemplate = null;
         this.query = query;
         this.parameterSource = null;
@@ -91,6 +94,7 @@ public class SqlConsumer extends 
ScheduledBatchPollingConsumer {
                        SqlPrepareStatementStrategy 
sqlPrepareStatementStrategy, SqlProcessingStrategy sqlProcessingStrategy) {
         super(endpoint, processor);
         this.jdbcTemplate = null;
+        this.templateMaxRows = -1;
         this.namedJdbcTemplate = namedJdbcTemplate;
         this.query = query;
         this.parameterSource = parameterSource;
@@ -459,8 +463,9 @@ public class SqlConsumer extends 
ScheduledBatchPollingConsumer {
     public void setMaxMessagesPerPoll(int maxMessagesPerPoll) {
         super.setMaxMessagesPerPoll(maxMessagesPerPoll);
 
+        // 0 means no limit: use the maxRows of the template (template.maxRows)
         if (jdbcTemplate != null) {
-            jdbcTemplate.setMaxRows(maxMessagesPerPoll);
+            jdbcTemplate.setMaxRows(maxMessagesPerPoll > 0 ? 
maxMessagesPerPoll : templateMaxRows);
         }
     }
 
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
index cbbcb85247f8..b48745c1a4a0 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
@@ -142,10 +142,14 @@ public class SqlProducer extends DefaultProducer {
         } else {
             data = processInternal(exchange, statementCreator, sql, 
preparedQuery, shouldRetrieveGeneratedKeys);
         }
-        if (getEndpoint().getOutputHeader() != null) {
-            exchange.getIn().setHeader(getEndpoint().getOutputHeader(), data 
== EMPTY_RESULT ? null : data);
-        } else if (data != null && !getEndpoint().isNoop()) {
-            exchange.getIn().setBody(data == EMPTY_RESULT ? null : data);
+        // no data for an update or a batch: leave the message as is
+        if (data != null) {
+            Object value = data == EMPTY_RESULT ? null : data;
+            if (getEndpoint().getOutputHeader() != null) {
+                exchange.getIn().setHeader(getEndpoint().getOutputHeader(), 
value);
+            } else if (!getEndpoint().isNoop()) {
+                exchange.getIn().setBody(value);
+            }
         }
     }
 
@@ -226,15 +230,7 @@ public class SqlProducer extends DefaultProducer {
                     }
 
                     if (shouldRetrieveGeneratedKeys) {
-                        if (isResultSet) {
-                            // we won't return generated keys for SELECT 
statements
-                            
exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_DATA, 
Collections.emptyList());
-                            
exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_ROW_COUNT, 0);
-                        } else {
-                            List<?> generatedKeys = 
getEndpoint().queryForList(ps.getGeneratedKeys(), false);
-                            
exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_DATA, generatedKeys);
-                            
exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_ROW_COUNT, 
generatedKeys.size());
-                        }
+                        setGeneratedKeys(exchange, ps, isResultSet);
                     }
 
                     return data;
@@ -245,6 +241,18 @@ public class SqlProducer extends DefaultProducer {
         });
     }
 
+    private void setGeneratedKeys(Exchange exchange, PreparedStatement ps, 
boolean isResultSet) throws SQLException {
+        if (isResultSet) {
+            // we won't return generated keys for SELECT statements
+            exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_DATA, 
Collections.emptyList());
+            
exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_ROW_COUNT, 0);
+        } else {
+            List<?> generatedKeys = 
getEndpoint().queryForList(ps.getGeneratedKeys(), false);
+            exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_DATA, 
generatedKeys);
+            
exchange.getIn().setHeader(SqlConstants.SQL_GENERATED_KEYS_ROW_COUNT, 
generatedKeys.size());
+        }
+    }
+
     protected Object processStreamList(
             Exchange exchange, PreparedStatementCreator statementCreator, 
String sql, String preparedQuery)
             throws Exception {
@@ -269,6 +277,9 @@ public class SqlProducer extends DefaultProducer {
             populateStatement(ps, exchange, sql, preparedQuery);
 
             boolean isResultSet = ps.execute();
+            if 
(exchange.getIn().getHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, false, 
Boolean.class)) {
+                setGeneratedKeys(exchange, ps, isResultSet);
+            }
             if (isResultSet) {
                 rs = ps.getResultSet();
                 iterator = getEndpoint().queryForStreamList(con, ds, ps, rs);
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/CallableStatementWrapper.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/CallableStatementWrapper.java
index 6a2fa6542aef..f7a4c5604979 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/CallableStatementWrapper.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/CallableStatementWrapper.java
@@ -27,6 +27,7 @@ import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.sql.stored.template.ast.InParameter;
+import org.apache.camel.support.ExchangeHelper;
 import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.CallableStatementCallback;
 import org.springframework.jdbc.core.CallableStatementCreator;
@@ -109,11 +110,26 @@ public class CallableStatementWrapper implements 
StatementWrapper {
             this.batchFactory = factory.getTemplateForBatch(template);
         }
 
-        Map<String, Object> batchValues = new HashMap<>();
         //only IN-parameters supported by template
+        List<InParameter> params = new ArrayList<>();
+        boolean simpleExpression = false;
         for (Object param : 
this.batchFactory.getTemplate().getParameterList()) {
             InParameter inputParameter = (InParameter) param;
-            Object paramValue = 
inputParameter.getValueExtractor().eval(exchange, value);
+            params.add(inputParameter);
+            simpleExpression |= inputParameter.isSimpleExpression();
+        }
+
+        // a simple expression such as ${body} must refer to the batch item 
and not to the whole message body, so
+        // evaluate it on a copy of the exchange with the item as body; the 
copy is not needed for :#name parameters
+        Exchange itemExchange = exchange;
+        if (simpleExpression) {
+            itemExchange = ExchangeHelper.createCopy(exchange, true);
+            itemExchange.getMessage().setBody(value);
+        }
+
+        Map<String, Object> batchValues = new HashMap<>();
+        for (InParameter inputParameter : params) {
+            Object paramValue = 
inputParameter.getValueExtractor().eval(itemExchange, value);
             batchValues.put(inputParameter.getName(), paramValue);
         }
         if (this.batchItems == null) {
diff --git 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/InParameter.java
 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/InParameter.java
index b94af655e383..13e0fbdb4f6f 100644
--- 
a/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/InParameter.java
+++ 
b/components/camel-sql/src/main/java/org/apache/camel/component/sql/stored/template/ast/InParameter.java
@@ -28,6 +28,7 @@ public class InParameter {
     private final int sqlType;
     private final Integer scale;
     private ValueExtractor valueExtractor;
+    private boolean simpleExpression;
 
     public InParameter(String name, int sqlType, Token valueSrcToken, Integer 
scale, String typeName) {
         this.name = name;
@@ -44,6 +45,7 @@ public class InParameter {
 
     private void parseValueExpression(Token valueSrcToken) {
         if (SSPTParserConstants.SIMPLE_EXP_TOKEN == valueSrcToken.kind) {
+            this.simpleExpression = true;
             this.valueExtractor = (exchange, container) -> {
                 Expression exp = 
exchange.getContext().resolveLanguage("simple").createExpression(valueSrcToken.toString());
                 return exp.evaluate(exchange, Object.class);
@@ -71,6 +73,13 @@ public class InParameter {
         return sqlType;
     }
 
+    /**
+     * Whether the value is a simple expression, which is evaluated against 
the exchange.
+     */
+    public boolean isSimpleExpression() {
+        return simpleExpression;
+    }
+
     public ValueExtractor getValueExtractor() {
         return valueExtractor;
     }
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentUsePlaceholderTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentUsePlaceholderTest.java
new file mode 100644
index 000000000000..61fd8741bfa9
--- /dev/null
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlComponentUsePlaceholderTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sql;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * The usePlaceholder option of the endpoint must apply to the query of the 
URI and to the onConsume queries, and
+ * override the option of the component (CAMEL-27893). Before, only the 
component option was used for them.
+ */
+public class SqlComponentUsePlaceholderTest extends CamelTestSupport {
+
+    private static final String URI_QUERY = "select * from projects where id = 
#";
+    private static final String ON_CONSUME = "update projects set processed = 
true where id = #";
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        // no connection is opened, the endpoints only need a DataSource for 
their JdbcTemplate
+        DriverManagerDataSource ds = new DriverManagerDataSource();
+        context.getComponent("sql", SqlComponent.class).setDataSource(ds);
+
+        SqlComponent noPlaceholder = new SqlComponent();
+        noPlaceholder.setDataSource(ds);
+        noPlaceholder.setUsePlaceholder(false);
+        context.addComponent("sqlNoPlaceholder", noPlaceholder);
+        return context;
+    }
+
+    @Test
+    public void defaultReplacesPlaceholder() {
+        SqlEndpoint endpoint = context.getEndpoint("sql:" + URI_QUERY + 
"?onConsume=" + ON_CONSUME, SqlEndpoint.class);
+
+        assertEquals("select * from projects where id = ?", 
endpoint.getQuery());
+        assertEquals("update projects set processed = true where id = ?", 
endpoint.getOnConsume());
+    }
+
+    @Test
+    public void endpointUsePlaceholderFalseKeepsPlaceholder() {
+        SqlEndpoint endpoint = context.getEndpoint(
+                "sql:" + URI_QUERY + "?usePlaceholder=false&onConsume=" + 
ON_CONSUME + "&onConsumeFailed=" + ON_CONSUME
+                                                   + 
"&onConsumeBatchComplete=" + ON_CONSUME,
+                SqlEndpoint.class);
+
+        // the # must reach the database as is, for example for a column or a 
string that contains it
+        assertEquals(URI_QUERY, endpoint.getQuery());
+        assertEquals(ON_CONSUME, endpoint.getOnConsume());
+        assertEquals(ON_CONSUME, endpoint.getOnConsumeFailed());
+        assertEquals(ON_CONSUME, endpoint.getOnConsumeBatchComplete());
+    }
+
+    @Test
+    public void endpointUsePlaceholderTrueOverridesComponent() {
+        SqlEndpoint endpoint = context.getEndpoint(
+                "sqlNoPlaceholder:" + URI_QUERY + 
"?usePlaceholder=true&onConsume=" + ON_CONSUME, SqlEndpoint.class);
+
+        assertEquals("select * from projects where id = ?", 
endpoint.getQuery());
+        assertEquals("update projects set processed = true where id = ?", 
endpoint.getOnConsume());
+    }
+
+    @Test
+    public void componentUsePlaceholderFalseIsTheDefaultOfTheEndpoints() {
+        SqlEndpoint endpoint = context.getEndpoint("sqlNoPlaceholder:" + 
URI_QUERY, SqlEndpoint.class);
+
+        assertEquals(URI_QUERY, endpoint.getQuery());
+    }
+}
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlConsumerTemplateMaxRowsTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlConsumerTemplateMaxRowsTest.java
new file mode 100644
index 000000000000..dc2246e375e9
--- /dev/null
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlConsumerTemplateMaxRowsTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.sql;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * template.maxRows limits the rows of a poll when maxMessagesPerPoll is not 
set (CAMEL-27893). Before, the consumer
+ * always set maxMessagesPerPoll (0 by default) as the maxRows of the 
template, which removed the limit.
+ */
+public class SqlConsumerTemplateMaxRowsTest extends CamelTestSupport {
+
+    private EmbeddedDatabase db;
+
+    @Override
+    public void doPreSetup() throws Exception {
+        // 3 projects, none of them processed
+        db = new EmbeddedDatabaseBuilder()
+                .setName(getClass().getSimpleName())
+                .setType(EmbeddedDatabaseType.HSQL)
+                .addScript("sql/createAndPopulateDatabase4.sql")
+                .build();
+    }
+
+    @Override
+    public void doPostTearDown() throws Exception {
+        if (db != null) {
+            db.shutdown();
+        }
+    }
+
+    @Test
+    public void templateMaxRowsLimitsThePoll() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(3);
+        MockEndpoint.assertIsSatisfied(context);
+
+        // the first poll reads 2 of the 3 rows, the next poll the last one
+        Exchange first = mock.getReceivedExchanges().get(0);
+        assertEquals(2, first.getProperty(Exchange.BATCH_SIZE));
+        Exchange third = mock.getReceivedExchanges().get(2);
+        assertEquals(1, third.getProperty(Exchange.BATCH_SIZE));
+    }
+
+    @Test
+    public void resetMaxMessagesPerPollRestoresTemplateMaxRows() throws 
Exception {
+        SqlEndpoint endpoint = context.getEndpoint("sql:select * from 
projects?template.maxRows=2", SqlEndpoint.class);
+        SqlConsumer consumer = (SqlConsumer) endpoint.createConsumer(exchange 
-> {
+        });
+
+        // maxMessagesPerPoll overrides the maxRows of the template
+        consumer.setMaxMessagesPerPoll(5);
+        assertEquals(5, endpoint.getJdbcTemplate().getMaxRows());
+
+        // back to 0 (no limit), the template.maxRows applies again instead of 
the stale 5
+        consumer.setMaxMessagesPerPoll(0);
+        assertEquals(2, endpoint.getJdbcTemplate().getMaxRows());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                getContext().getComponent("sql", 
SqlComponent.class).setDataSource(db);
+
+                from("sql:select * from projects where processed = false order 
by id?template.maxRows=2&initialDelay=0&delay=50")
+                        .to("mock:result")
+                        .to("sql:update projects set processed = true where id 
= :#id");
+            }
+        };
+    }
+}
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
index 7ecb0b3ec97e..372e0ac32e7e 100644
--- 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlGeneratedKeysTest.java
@@ -65,6 +65,8 @@ public class SqlGeneratedKeysTest extends CamelTestSupport {
                 from("direct:insert").to("sql:insert into projects (project, 
license, description) values (#, #, #)");
                 from("direct:batch").to("sql:insert into projects (project, 
license, description) values (#, #, #)?batch=true");
                 from("direct:select").to("sql:select * from projects order by 
id asc");
+                from("direct:insertStream")
+                        .to("sql:insert into projects (project, license, 
description) values (#, #, #)?outputType=StreamList");
                 from("direct:insert2").to("sql:insert into developers (name, 
position) values (#, #)");
             }
         };
@@ -102,6 +104,26 @@ public class SqlGeneratedKeysTest extends CamelTestSupport 
{
                 "generated keys row count should be one");
     }
 
+    @Test
+    @SuppressWarnings("unchecked")
+    public void testRetrieveGeneratedKeyWithStreamList() {
+        // the StreamList producer prepared the statement with 
RETURN_GENERATED_KEYS but never read the keys (CAMEL-27893)
+        Endpoint endpoint = context.getEndpoint("direct:insertStream");
+
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody(new Object[] { "project x", "ASF", "new 
project" });
+        exchange.getIn().setHeader(SqlConstants.SQL_RETRIEVE_GENERATED_KEYS, 
true);
+
+        Exchange out = template.send(endpoint, exchange);
+
+        List<Map<String, Object>> generatedKeys = 
out.getMessage().getHeader(SqlConstants.SQL_GENERATED_KEYS_DATA, List.class);
+        assertNotNull(generatedKeys);
+        assertEquals(1, generatedKeys.size());
+        assertEquals(3, generatedKeys.get(0).get("ID"), "auto increment value 
should be 3");
+        assertEquals(1, 
out.getMessage().getHeader(SqlConstants.SQL_GENERATED_KEYS_ROW_COUNT));
+        assertEquals(1, 
out.getMessage().getHeader(SqlConstants.SQL_UPDATE_COUNT));
+    }
+
     @Test
     @SuppressWarnings("unchecked")
     public void testRetrieveGeneratedKeys() {
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderTest.java
index 6d836414edb9..1c6d45b8dd7d 100644
--- 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderTest.java
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerOutputHeaderTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.sql;
 
+import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit6.CamelTestSupport;
@@ -24,6 +25,10 @@ import 
org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 public class SqlProducerOutputHeaderTest extends CamelTestSupport {
 
     private EmbeddedDatabase db;
@@ -59,6 +64,24 @@ public class SqlProducerOutputHeaderTest extends 
CamelTestSupport {
         MockEndpoint.assertIsSatisfied(context);
     }
 
+    @Test
+    public void testUpdateDoesNotSetOutputHeader() {
+        // an update has no result: the header must keep its value instead of 
being set to null (CAMEL-27893)
+        Exchange out = template.request("direct:update", e -> 
e.getIn().setHeader("Result", "unchanged"));
+
+        assertEquals("unchanged", out.getMessage().getHeader("Result"));
+        assertEquals(1, 
out.getMessage().getHeader(SqlConstants.SQL_UPDATE_COUNT));
+    }
+
+    @Test
+    public void testSelectOneWithoutRowSetsOutputHeaderToNull() {
+        // no row is a result (like the body is set to null without 
outputHeader), so the header is set to null
+        Exchange out = template.request("direct:noRow", e -> 
e.getIn().setHeader("Result", "previous"));
+
+        assertTrue(out.getMessage().getHeaders().containsKey("Result"));
+        assertNull(out.getMessage().getHeader("Result"));
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
@@ -69,6 +92,9 @@ public class SqlProducerOutputHeaderTest extends 
CamelTestSupport {
 
                 from("direct:query").to("sql:select max(id) from 
projects?outputType=SelectOne&outputHeader=MaxProjectID")
                         .to("mock:query");
+                from("direct:update").to("sql:update projects set license = 
'XXX' where id = 1?outputHeader=Result");
+                from("direct:noRow")
+                        .to("sql:select project from projects where id = 
999?outputType=SelectOne&outputHeader=Result");
             }
         };
     }
diff --git 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/CallableStatementWrapperTest.java
 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/CallableStatementWrapperTest.java
index f54841dd6892..7f2fcdfedaaf 100644
--- 
a/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/CallableStatementWrapperTest.java
+++ 
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/stored/CallableStatementWrapperTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.sql.stored;
 
 import java.sql.SQLException;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.Exchange;
@@ -106,6 +107,26 @@ public class CallableStatementWrapperTest extends 
CamelTestSupport {
         });
     }
 
+    @Test
+    public void shouldEvaluateSimpleExpressionOnEachBatchItem() {
+        // ${body} must be the batch item, not the whole message body, so each 
item gets its own value (CAMEL-27893)
+        CallableStatementWrapper wrapper = new 
CallableStatementWrapper("BATCHFN(VARCHAR ${body[num]})", factory);
+
+        Map<String, Object> item1 = Map.of("num", "1");
+        Map<String, Object> item2 = Map.of("num", "3");
+        Exchange exchange = createExchangeWithBody(List.of(item1, item2));
+        exchange.getIn().setHeader("num", "header");
+
+        wrapper.addBatch(item1, exchange);
+        wrapper.addBatch(item2, exchange);
+
+        assertEquals(2, wrapper.batchItems.size());
+        assertEquals(List.of("1"), 
List.copyOf(wrapper.batchItems.get(0).values()));
+        assertEquals(List.of("3"), 
List.copyOf(wrapper.batchItems.get(1).values()));
+        // the message body of the exchange is not changed
+        assertEquals(List.of(item1, item2), exchange.getIn().getBody());
+    }
+
     @Override
     public void doPostTearDown() throws Exception {
         if (db != null) {
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
index 189aaadc1034..52dba94c1356 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
@@ -614,3 +614,25 @@ variables and the JVM system properties even when 
`camel.main.autoConfigurationE
 ignored them. Now these two options ignore a disabled source too: for example 
`CAMEL_MAIN_VIRTUALTHREADSENABLED=true`
 no longer turns on virtual threads when the OS environment variables are 
disabled. Set the option in
 `application.properties` instead, or enable the source again.
+
+
+=== camel-sql and camel-sql-stored - usePlaceholder, maxRows, outputHeader and 
batch expressions
+
+The `usePlaceholder` option of a `sql` endpoint now applies to the query in 
the URI and to the `onConsume`,
+`onConsumeFailed` and `onConsumeBatchComplete` queries. Before, these queries 
followed only the `usePlaceholder`
+option of the component, so `usePlaceholder=false` on the endpoint did not 
keep a `#` in them. An endpoint with
+`usePlaceholder=false` now sends `#` to the database as is: replace it with 
`?` in such a query.
+
+The `sql` consumer no longer resets `template.maxRows` when 
`maxMessagesPerPoll` is not set (`0`, the default), so
+`template.maxRows` now limits the rows of a poll. When `maxMessagesPerPoll` is 
set, it still takes precedence.
+
+The `sql` producer no longer sets the header that `outputHeader` names to 
`null` when the query has no result (an
+update or `batch=true`); the header keeps its previous value, or stays absent. 
A `SelectOne` query without a row
+still sets it to `null`.
+
+With `outputType=StreamList`, the `sql` producer now reads the generated keys 
when the `CamelSqlRetrieveGeneratedKeys`
+header is `true`, into the `CamelSqlGeneratedKeyRows` and 
`CamelSqlGeneratedKeysRowCount` headers.
+
+With `batch=true`, the `sql-stored` producer now evaluates a simple expression 
of an IN parameter (such as
+`+${body[num]}+`) with the batch item as the message body, as `:#name` already 
did. Before, `+${body}+` referred to the
+whole message body, so every item got the same value.
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SqlComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SqlComponentBuilderFactory.java
index b16c0a0f29e8..61efac2cf3f5 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SqlComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SqlComponentBuilderFactory.java
@@ -225,7 +225,9 @@ public interface SqlComponentBuilderFactory {
         /**
          * Whether to replace the placeholder of the endpoints (the placeholder
          * option, # by default) with ? in their queries: the query and the
-         * onConsume, onConsumeFailed and onConsumeBatchComplete queries.
+         * onConsume, onConsumeFailed and onConsumeBatchComplete queries. This
+         * is the default for all sql endpoints and can be overridden per
+         * endpoint.
          * 
          * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
          * 
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SqlEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SqlEndpointBuilderFactory.java
index 3328653f79d7..4ad80feb3c6d 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SqlEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SqlEndpointBuilderFactory.java
@@ -302,10 +302,11 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * The maximum number of rows that a poll reads. It is set as the
-         * maxRows of the JdbcTemplate (Statement.setMaxRows), so the database
-         * returns at most this many rows, and it replaces template.maxRows. 0
-         * (the default) means no limit.
+         * The maximum number of rows that a poll reads. When set, it is set as
+         * the maxRows of the JdbcTemplate (Statement.setMaxRows), so the
+         * database returns at most this many rows, and it replaces
+         * template.maxRows. 0 (the default) means no limit, other than
+         * template.maxRows.
          * 
          * The option is a: <code>int</code> type.
          * 
@@ -319,10 +320,11 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * The maximum number of rows that a poll reads. It is set as the
-         * maxRows of the JdbcTemplate (Statement.setMaxRows), so the database
-         * returns at most this many rows, and it replaces template.maxRows. 0
-         * (the default) means no limit.
+         * The maximum number of rows that a poll reads. When set, it is set as
+         * the maxRows of the JdbcTemplate (Statement.setMaxRows), so the
+         * database returns at most this many rows, and it replaces
+         * template.maxRows. 0 (the default) means no limit, other than
+         * template.maxRows.
          * 
          * The option will be converted to a <code>int</code> type.
          * 
@@ -1464,10 +1466,10 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether to replace the placeholder with ? in a query loaded from a
-         * resource (file: or classpath:) and in the CamelSqlQuery header. The
-         * query in the URI and the onConsume queries follow the usePlaceholder
-         * option of the component.
+         * Whether to replace the placeholder with ? in the queries: the query
+         * of the endpoint (also when it is loaded from a resource, such as
+         * file: or classpath:), the onConsume, onConsumeFailed and
+         * onConsumeBatchComplete queries, and the CamelSqlQuery header.
          * 
          * The option is a: <code>boolean</code> type.
          * 
@@ -1482,10 +1484,10 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether to replace the placeholder with ? in a query loaded from a
-         * resource (file: or classpath:) and in the CamelSqlQuery header. The
-         * query in the URI and the onConsume queries follow the usePlaceholder
-         * option of the component.
+         * Whether to replace the placeholder with ? in the queries: the query
+         * of the endpoint (also when it is loaded from a resource, such as
+         * file: or classpath:), the onConsume, onConsumeFailed and
+         * onConsumeBatchComplete queries, and the CamelSqlQuery header.
          * 
          * The option will be converted to a <code>boolean</code> type.
          * 
@@ -2179,10 +2181,10 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether to replace the placeholder with ? in a query loaded from a
-         * resource (file: or classpath:) and in the CamelSqlQuery header. The
-         * query in the URI and the onConsume queries follow the usePlaceholder
-         * option of the component.
+         * Whether to replace the placeholder with ? in the queries: the query
+         * of the endpoint (also when it is loaded from a resource, such as
+         * file: or classpath:), the onConsume, onConsumeFailed and
+         * onConsumeBatchComplete queries, and the CamelSqlQuery header.
          * 
          * The option is a: <code>boolean</code> type.
          * 
@@ -2197,10 +2199,10 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether to replace the placeholder with ? in a query loaded from a
-         * resource (file: or classpath:) and in the CamelSqlQuery header. The
-         * query in the URI and the onConsume queries follow the usePlaceholder
-         * option of the component.
+         * Whether to replace the placeholder with ? in the queries: the query
+         * of the endpoint (also when it is loaded from a resource, such as
+         * file: or classpath:), the onConsume, onConsumeFailed and
+         * onConsumeBatchComplete queries, and the CamelSqlQuery header.
          * 
          * The option will be converted to a <code>boolean</code> type.
          * 
@@ -2666,10 +2668,10 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether to replace the placeholder with ? in a query loaded from a
-         * resource (file: or classpath:) and in the CamelSqlQuery header. The
-         * query in the URI and the onConsume queries follow the usePlaceholder
-         * option of the component.
+         * Whether to replace the placeholder with ? in the queries: the query
+         * of the endpoint (also when it is loaded from a resource, such as
+         * file: or classpath:), the onConsume, onConsumeFailed and
+         * onConsumeBatchComplete queries, and the CamelSqlQuery header.
          * 
          * The option is a: <code>boolean</code> type.
          * 
@@ -2684,10 +2686,10 @@ public interface SqlEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether to replace the placeholder with ? in a query loaded from a
-         * resource (file: or classpath:) and in the CamelSqlQuery header. The
-         * query in the URI and the onConsume queries follow the usePlaceholder
-         * option of the component.
+         * Whether to replace the placeholder with ? in the queries: the query
+         * of the endpoint (also when it is loaded from a resource, such as
+         * file: or classpath:), the onConsume, onConsumeFailed and
+         * onConsumeBatchComplete queries, and the CamelSqlQuery header.
          * 
          * The option will be converted to a <code>boolean</code> type.
          * 
@@ -2833,7 +2835,6 @@ public interface SqlEndpointBuilderFactory {
          * Whether to retrieve the keys that the database generates for an
          * insert (Statement.RETURN_GENERATED_KEYS) into the
          * CamelSqlGeneratedKeyRows and CamelSqlGeneratedKeysRowCount headers.
-         * Not supported with outputType=StreamList.
          * 
          * The option is a: {@code Boolean} type.
          * 

Reply via email to