Class SqlParameterSourceUtils
- java.lang.Object
- org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils
public class SqlParameterSourceUtils extends Object
Class that provides helper methods for the use ofSqlParameterSource
, in particular withNamedParameterJdbcTemplate
.- Since:
- 2.5
- Author:
- Thomas Risberg, Juergen Hoeller
Constructor Summary
Constructors Constructor Description SqlParameterSourceUtils()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SqlParameterSource[]
createBatch(Object[] beans)
Create an array ofBeanPropertySqlParameterSource
objects populated with data from the values passed in.static SqlParameterSource[]
createBatch(Map<String,?>[] valueMaps)
Create an array ofMapSqlParameterSource
objects populated with data from the values passed in.static Map<String,String>
extractCaseInsensitiveParameterNames(SqlParameterSource parameterSource)
Create a Map of case insensitive parameter names together with the original name.static Object
getTypedValue(SqlParameterSource source, String parameterName)
Create a wrapped value if parameter has type information, plain object if not.
Constructor Detail
SqlParameterSourceUtils
public SqlParameterSourceUtils()
Method Detail
createBatch
public static SqlParameterSource[] createBatch(Map<String,?>[] valueMaps)
Create an array ofMapSqlParameterSource
objects populated with data from the values passed in. This will define what is included in a batch operation.- Parameters:
valueMaps
- array ofMap
instances containing the values to be used- Returns:
- an array of
SqlParameterSource
- See Also:
MapSqlParameterSource
,NamedParameterJdbcTemplate.batchUpdate(String, Map[])
createBatch
public static SqlParameterSource[] createBatch(Object[] beans)
Create an array ofBeanPropertySqlParameterSource
objects populated with data from the values passed in. This will define what is included in a batch operation.- Parameters:
beans
- object array of beans containing the values to be used- Returns:
- an array of
SqlParameterSource
- See Also:
BeanPropertySqlParameterSource
,NamedParameterJdbcTemplate.batchUpdate(String, SqlParameterSource[])
getTypedValue
public static Object getTypedValue(SqlParameterSource source, String parameterName)
Create a wrapped value if parameter has type information, plain object if not.- Parameters:
source
- the source of parameter values and type informationparameterName
- the name of the parameter- Returns:
- the value object
- See Also:
SqlParameterValue
extractCaseInsensitiveParameterNames
public static Map<String,String> extractCaseInsensitiveParameterNames(SqlParameterSource parameterSource)
Create a Map of case insensitive parameter names together with the original name.- Parameters:
parameterSource
- the source of parameter names- Returns:
- the Map that can be used for case insensitive matching of parameter names