Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Not A Problem
-
JDO 3.1
-
None
-
None
Description
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);