public class

MapSqlParameterSource

extends AbstractSqlParameterSource
java.lang.Object
   ↳ org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
     ↳ org.springframework.jdbc.core.namedparam.MapSqlParameterSource

Class Overview

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.

Summary

[Expand]
Inherited Constants
From interface org.springframework.jdbc.core.namedparam.SqlParameterSource
Public Constructors
MapSqlParameterSource()
Create an empty MapSqlParameterSource, with values to be added via addValue.
MapSqlParameterSource(String paramName, Object value)
Create a new MapSqlParameterSource, with one value comprised of the supplied arguments.
MapSqlParameterSource(Map<String, ?> values)
Create a new MapSqlParameterSource based on a Map.
Public Methods
MapSqlParameterSource addValue(String paramName, Object value)
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 addValue(String paramName, Object value, int sqlType)
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)
Map<StringObject> getValues()
Expose the current parameter values as read-only Map.
boolean hasValue(String paramName)
[Expand]
Inherited Methods
From class org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
From class java.lang.Object
From interface org.springframework.jdbc.core.namedparam.SqlParameterSource

Public Constructors

public MapSqlParameterSource ()

Create an empty MapSqlParameterSource, with values to be added via addValue.

public MapSqlParameterSource (String paramName, Object value)

Create a new MapSqlParameterSource, with one value comprised of the supplied arguments.

Parameters
paramName the name of the parameter
value the value of the parameter

public MapSqlParameterSource (Map<String, ?> values)

Create a new MapSqlParameterSource based on a Map.

Parameters
values a Map holding existing parameter values (can be null)

Public Methods

public MapSqlParameterSource addValue (String paramName, Object value)

Add a parameter to this parameter source.

Parameters
paramName the name of the parameter
value the value of the parameter
Returns
  • a reference to this parameter source, so it's possible to chain several calls together

public MapSqlParameterSource addValue (String paramName, Object value, int sqlType, String typeName)

Add a parameter to this parameter source.

Parameters
paramName the name of the parameter
value the value of the parameter
sqlType the SQL type of the parameter
typeName the type name of the parameter
Returns
  • a reference to this parameter source, so it's possible to chain several calls together

public MapSqlParameterSource addValue (String paramName, Object value, int sqlType)

Add a parameter to this parameter source.

Parameters
paramName the name of the parameter
value the value of the parameter
sqlType the SQL type of the parameter
Returns
  • a reference to this parameter source, so it's possible to chain several calls together

public MapSqlParameterSource addValues (Map<String, ?> values)

Add a Map of parameters to this parameter source.

Parameters
values a Map holding existing parameter values (can be null)
Returns
  • a reference to this parameter source, so it's possible to chain several calls together

public Object getValue (String paramName)

public Map<StringObject> getValues ()

Expose the current parameter values as read-only Map.

public boolean hasValue (String paramName)