This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch feature/CAMEL-23789-wave1-multi-dsl-docs in repository https://gitbox.apache.org/repos/asf/camel.git
commit ea3b220a20dbd26e355833a619ac710d25e78233 Author: Claus Ibsen <[email protected]> AuthorDate: Wed Jun 17 19:26:03 2026 +0200 CAMEL-23789: Make SQL component docs multi-DSL friendly (Wave 1) Co-Authored-By: Claude <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel-sql/src/main/docs/sql-component.adoc | 53 +++++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/components/camel-sql/src/main/docs/sql-component.adoc b/components/camel-sql/src/main/docs/sql-component.adoc index 24b10f99095b..d0ca70c5298d 100644 --- a/components/camel-sql/src/main/docs/sql-component.adoc +++ b/components/camel-sql/src/main/docs/sql-component.adoc @@ -145,7 +145,7 @@ the size of the outer iterator determines the batch size. You can use the option `useMessageBodyForSql` that allows to use the message body as the SQL statement, and then the SQL parameters must be provided in a header with the -key `SqlConstants.SQL_PARAMETERS`. This allows the SQL component to work +key `CamelSqlParameters`. This allows the SQL component to work more dynamically as the SQL query is from the message body. Use templating (such as xref:components::velocity-component.adoc[Velocity], xref:components::freemarker-component.adoc[Freemarker]) for conditional processing, e.g., to include or exclude `where` clauses @@ -211,6 +211,10 @@ The producer supports `outputType=StreamList` that uses an iterator to stream th This allows processing the data in a streaming fashion which, for example, can be used by the Splitter EIP to process each row one at a time, and load data from the database as needed. +[tabs] +==== +Java:: ++ [source,java] ---- from("direct:withSplitModel") @@ -222,6 +226,49 @@ from("direct:withSplitModel") .end(); ---- +XML:: ++ +[source,xml] +---- +<route> + <from uri="direct:withSplitModel"/> + <to uri="sql:select * from projects order by id?outputType=StreamList&outputClass=org.apache.camel.component.sql.ProjectModel"/> + <to uri="log:stream"/> + <split streaming="true"> + <simple>${body}</simple> + <to uri="log:row"/> + <to uri="mock:result"/> + </split> +</route> +---- + +YAML:: ++ +[source,yaml] +---- +- route: + from: + uri: direct:withSplitModel + steps: + - to: + uri: "sql:select * from projects order by id" + parameters: + outputType: StreamList + outputClass: org.apache.camel.component.sql.ProjectModel + - to: + uri: log:stream + - split: + expression: + simple: "${body}" + streaming: true + steps: + - to: + uri: log:row + - to: + uri: mock:result +---- +==== + === Generated keys If you insert data using SQL INSERT, then the RDBMS may support auto @@ -519,6 +566,7 @@ YAML:: Then the IN query can use a header with the key names with the dynamic values such as: +._Java-only: uses `ProducerTemplate` test API_ [source,java] ---- // use an array @@ -600,12 +648,13 @@ the custom data source. For example in the code snippet below, we set the header `CamelSqlDataSource` with a custom `javax.sql.DataSource` instance. +._Java-only: requires setting a `DataSource` object reference programmatically_ [source,java] ---- DataSource custom = ... from("direct:query") - .setHeader("CamelSqlDataSource", custom) + .setHeader("CamelSqlDataSource", constant(custom)) .to("sql:query.sql") .to("bean:processData"); ----
