davsclaus opened a new pull request, #28918: URL: https://github.com/apache/camel/pull/28918
Fixes [CAMEL-26148](https://issues.apache.org/jira/browse/CAMEL-26148). ### 1. With `batch=true`, `CamelSqlStoredUpdateCount` could be negative **What was wrong:** `SqlStoredProducer` summed every value returned by `executeBatch()` into the header. A JDBC driver may return `Statement.SUCCESS_NO_INFO` (-2) for an item whose count it does not know. HSQLDB does this for stored procedure calls, so a batch of 2 items reported `-4`. **What changed:** only positive counts are added to the total. When the driver reports no counts, the header is `0`. The header description, the `@BodyTypes` text and the component doc now say this. ### 2. With `batch=true`, a single Map body iterated the map entries **What was wrong:** the batch items were taken with `getBody(Iterator.class)`. For a `Map` that gives an iterator over its entries, so each `Map.Entry` became a batch item and the call failed with an `SQLException` that did not point to the body. The same happened for a Map in the `CamelSqlStoredParameters` header with `useMessageBodyForTemplate=true`. **What changed:** a single `Map` (body or header) is now one batch item. This matches how any other single value (a POJO, for example) is already treated as one batch item. `Carrier.MAP` is added to the batch carriers of `@BodyTypes`. ### Tests In `ProducerBatchTest` (HSQLDB, no external service): - `shouldExecuteBatch` now also asserts the update count is `0` (it was `-4` before the fix). - `shouldExecuteSingleMapBodyAsOneBatchItem` and `shouldExecuteSingleMapHeaderAsOneBatchItem` are new; both failed before the fix with `BatchUpdateException: Java execution: BATCHFN`. `mvn clean install -Psourcecheck` in `components/camel-sql`: 329 tests, 0 failures. ### Docs and generated files - New "Batch" section in `sql-stored-component.adoc`. - Upgrade guide entry under `camel-sql` (the header value changes for drivers that return `SUCCESS_NO_INFO`). - Regenerated `sql-stored.json` (component and catalog), the catalog doc copy, and `SqlStoredEndpointBuilderFactory`. ### Not changed The `sql` component (`SqlProducer`) has the same two patterns in its batch mode (it sums negative counts into `CamelSqlUpdateCount` and uses `getBody(Iterator.class)`). It is left as is to keep this PR on the reported `sql-stored` bugs. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
