[
https://issues.apache.org/jira/browse/CAMEL-26533?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-26533.
---------------------------------
Resolution: Fixed
Merged to main in https://github.com/apache/camel/pull/29084
_Claude Code on behalf of Claus Ibsen_
> camel-jpa - bind CamelJpaParameters header values literally
> -----------------------------------------------------------
>
> Key: CAMEL-26533
> URL: https://issues.apache.org/jira/browse/CAMEL-26533
> Project: Camel
> Issue Type: Bug
> Components: camel-jpa
> Reporter: Andrea Cosentino
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 4.18.6, 4.22.3, 4.24.0
>
>
> The camel-jpa producer ({{JpaProducer.configureParameters}}) configures query
> parameters for JPA queries. When parameters are not specified on the
> endpoint, the producer reads parameter mappings from the
> {{CamelJpaParameters}} header ({{Map<String, Object>}}). For each entry in
> the header map, if the value is an instance of {{String}}, it is evaluated as
> a Simple expression ({{simple.createExpression(str).evaluate(exchange,
> Object.class)}}).
> h3. Current behaviour
> When query parameters are supplied via the {{CamelJpaParameters}} header, any
> {{String}} parameter value is evaluated as a Simple expression with the
> exchange in scope.
> h3. Behaviour after the change
> The producer separates endpoint configuration from message headers:
> * Parameter values supplied through the {{CamelJpaParameters}} header are
> bound directly and literally with {{query.setParameter(key, value)}} without
> expression evaluation.
> * The endpoint-level {{parameters}} option continues to support Simple
> expression evaluation as documented for route configuration.
> h3. Classes involved
> *
> {{components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java}}
> - {{configureParameters}}
> *
> {{components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaConstants.java}}
> - {{JPA_PARAMETERS_HEADER}} documentation
> h3. Code-level change
> * {{JpaProducer.configureParameters}}: bind values from the
> {{CamelJpaParameters}} header literally; do not evaluate {{String}} values as
> Simple expressions.
> * Retain Simple expression evaluation only for the endpoint {{parameters}}
> option.
> * Update documentation for {{CamelJpaParameters}} to clarify that header
> parameter values are bound literally.
> * Add an upgrade guide entry to
> {{docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc}}
> describing the literal parameter binding behaviour.
> h3. Tests
> Update {{JpaProducerWithQueryParametersHeaderTest}} to verify that {{String}}
> parameter values supplied in the {{CamelJpaParameters}} header are bound
> literally without expression evaluation. Add tests asserting that expressions
> like {{${body}}} or {{${header.id}}} remain literal strings in the query
> parameters.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)