类 MapSqlParameterSource
- java.lang.Object
- org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
- org.springframework.jdbc.core.namedparam.MapSqlParameterSource
- 所有已实现的接口:
SqlParameterSource
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 theMapSqlParameterSource
itself, so you can chain several method calls together within a single statement.- 从以下版本开始:
- 2.0
- 作者:
- Thomas Risberg, Juergen Hoeller
- 另请参阅:
addValue(String, Object)
,addValue(String, Object, int)
,AbstractSqlParameterSource.registerSqlType(java.lang.String, int)
,NamedParameterJdbcTemplate
字段概要
从接口继承的字段 org.springframework.jdbc.core.namedparam.SqlParameterSource
TYPE_UNKNOWN
构造器概要
构造器 构造器 说明 MapSqlParameterSource()
Create an empty MapSqlParameterSource, with values to be added viaaddValue
.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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.String[]
getParameterNames()
Enumerate all available parameter names if possible.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.从类继承的方法 org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
getSqlType, getTypeName, registerSqlType, registerTypeName, toString
构造器详细资料
MapSqlParameterSource
public MapSqlParameterSource()
Create an empty MapSqlParameterSource, with values to be added viaaddValue
.
MapSqlParameterSource
public MapSqlParameterSource(String paramName, @Nullable Object value)
Create a new MapSqlParameterSource, with one value comprised of the supplied arguments.- 参数:
paramName
- the name of the parametervalue
- the value of the parameter- 另请参阅:
addValue(String, Object)
MapSqlParameterSource
public MapSqlParameterSource(@Nullable Map<String,?> values)
Create a new MapSqlParameterSource based on a Map.- 参数:
values
- a Map holding existing parameter values (can benull
)
方法详细资料
addValue
public MapSqlParameterSource addValue(String paramName, @Nullable Object value)
Add a parameter to this parameter source.- 参数:
paramName
- the name of the parametervalue
- the value of the parameter- 返回:
- a reference to this parameter source, so it's possible to chain several calls together
addValue
public MapSqlParameterSource addValue(String paramName, @Nullable Object value, int sqlType)
Add a parameter to this parameter source.- 参数:
paramName
- the name of the parametervalue
- the value of the parametersqlType
- the SQL type of the parameter- 返回:
- a reference to this parameter source, so it's possible to chain several calls together
addValue
public MapSqlParameterSource addValue(String paramName, @Nullable Object value, int sqlType, String typeName)
Add a parameter to this parameter source.- 参数:
paramName
- the name of the parametervalue
- the value of the parametersqlType
- the SQL type of the parametertypeName
- the type name of the parameter- 返回:
- a reference to this parameter source, so it's possible to chain several calls together
addValues
public MapSqlParameterSource addValues(@Nullable Map<String,?> values)
Add a Map of parameters to this parameter source.- 参数:
values
- a Map holding existing parameter values (can benull
)- 返回:
- a reference to this parameter source, so it's possible to chain several calls together
getValues
public Map<String,Object> getValues()
Expose the current parameter values as read-only Map.
hasValue
public boolean hasValue(String paramName)
从接口复制的说明:SqlParameterSource
Determine whether there is a value for the specified named parameter.- 参数:
paramName
- the name of the parameter- 返回:
- whether there is a value defined
getValue
@Nullable public Object getValue(String paramName)
从接口复制的说明:SqlParameterSource
Return the parameter value for the requested named parameter.- 参数:
paramName
- the name of the parameter- 返回:
- the value of the specified parameter
getParameterNames
@NonNull public String[] getParameterNames()
从接口复制的说明:SqlParameterSource
Enumerate all available parameter names if possible.This is an optional operation, primarily for use with
SimpleJdbcInsert
andSimpleJdbcCall
.- 返回:
- the array of parameter names, or
null
if not determinable - 另请参阅:
SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(org.springframework.jdbc.core.namedparam.SqlParameterSource)