You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by "Craig L Russell (JIRA)" <ji...@apache.org> on 2017/06/13 16:34:00 UTC

[jira] [Closed] (JDO-762) setParameters and setNamedParameters should use thread local storage

     [ https://issues.apache.org/jira/browse/JDO-762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Craig L Russell closed JDO-762.
-------------------------------
       Resolution: Not A Problem
         Assignee: Craig L Russell
    Fix Version/s:     (was: JDO 3.2)

> 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
>            Assignee: Craig L Russell
>            Priority: Minor
>
> 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.4.14#64029)