public class MapSqlParameterSource extends AbstractSqlParameterSource
SqlParameterSource implementation that holds a given Map of parameters.
This class is intended for passing in a simple Map of parameter values
to the methods of the NamedParameterJdbcTemplate class.
The addValue methods on this class will make adding several
values easier. The methods return a reference to the MapSqlParameterSource
itself, so you can chain several method calls together within a single statement.
addValue(String, Object),
addValue(String, Object, int),
AbstractSqlParameterSource.registerSqlType(java.lang.String, int),
NamedParameterJdbcTemplateTYPE_UNKNOWN| Constructor and Description |
|---|
MapSqlParameterSource()
Create an empty MapSqlParameterSource,
with values to be added via
addValue. |
MapSqlParameterSource(Map<String,?> values)
Create a new MapSqlParameterSource based on a Map.
|
MapSqlParameterSource(String paramName,
Object value)
Create a new MapSqlParameterSource, with one value
comprised of the supplied arguments.
|
| Modifier and Type | Method and Description |
|---|---|
MapSqlParameterSource |
addValue(String paramName,
Object value)
Add a parameter to this parameter source.
|
MapSqlParameterSource |
addValue(String paramName,
Object value,
int sqlType)
Add a parameter to this parameter source.
|
MapSqlParameterSource |
addValue(String paramName,
Object value,
int sqlType,
String typeName)
Add a parameter to this parameter source.
|
MapSqlParameterSource |
addValues(Map<String,?> values)
Add a Map of parameters to this parameter source.
|
Object |
getValue(String paramName)
Return the parameter value for the requested named parameter.
|
Map<String,Object> |
getValues()
Expose the current parameter values as read-only Map.
|
boolean |
hasValue(String paramName)
Determine whether there is a value for the specified named parameter.
|
getSqlType, getTypeName, registerSqlType, registerTypeNamepublic MapSqlParameterSource()
addValue.addValue(String, Object)public MapSqlParameterSource(String paramName, Object value)
paramName - the name of the parametervalue - the value of the parameteraddValue(String, Object)public MapSqlParameterSource addValue(String paramName, Object value)
paramName - the name of the parametervalue - the value of the parameterpublic MapSqlParameterSource addValue(String paramName, Object value, int sqlType)
paramName - the name of the parametervalue - the value of the parametersqlType - the SQL type of the parameterpublic MapSqlParameterSource addValue(String paramName, Object value, int sqlType, String typeName)
paramName - the name of the parametervalue - the value of the parametersqlType - the SQL type of the parametertypeName - the type name of the parameterpublic MapSqlParameterSource addValues(Map<String,?> values)
values - a Map holding existing parameter values (can be null)public Map<String,Object> getValues()
public boolean hasValue(String paramName)
SqlParameterSourceparamName - the name of the parameterpublic Object getValue(String paramName)
SqlParameterSourceparamName - the name of the parameter