[ 
https://issues.apache.org/jira/browse/JDO-762?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15977018#comment-15977018
 ] 

Craig L Russell commented on JDO-762:
-------------------------------------

The setRange also affects the execution of the query so it should be considered 
part of what needs to be thread safe.

> setParameters and setNamedParameters should use thread local storage
> --------------------------------------------------------------------
>
>                 Key: JDO-762
>                 URL: https://issues.apache.org/jira/browse/JDO-762
>             Project: JDO
>          Issue Type: Improvement
>          Components: api
>    Affects Versions: JDO 3.1
>            Reporter: Craig L Russell
>            Priority: Minor
>             Fix For: JDO 3.2
>
>
> These methods are the only ones that can be used with the new execute methods 
> to set parameters.
> Sadly, they are not thread-safe, which is a problem considering that the 
> Query object is supposed to be thread-safe.
> Before we added new Query methods, the execute method provided the 
> parameters. But now, the only way to provide parameters with the new execute 
> methods is via the setParameters and setNamedParameters. This is especially 
> important for named queries where the nominal usage pattern is for the 
> implementation to store the (compiled) Query objects in a Map<String, Query>. 
> I'd like to update the description to include the expected thread behavior:
> * Parameter values are stored in thread local storage so the same Query object
> * can be used by multiple threads simultaneously.
>    /**
>     * Method to set the named parameters on this query prior to execution.
>     * If using the execute methods taking parameters then those parameter 
> values will override these values.
>     * All parameter values specified in this method will only be retained 
> until the subsequent query execution.
>     * @param namedParamMap The map of parameter values keyed by their names.
>     * @return This query
>     */
>    Query<T> setNamedParameters(Map<String, ?> namedParamMap);
>    /**
>     * Method to set the values of the numbered parameters on this query prior 
> to execution.
>     * If using the execute methods taking parameters then those parameter 
> values will override these values.
>     * All parameter values specified in this method will only be retained 
> until the subsequent query execution.
>     * @param paramValues Values of the numbered parameters, in order.
>     * @return This query
>     */
>    Query<T> setParameters(Object... paramValues);



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to