Class AbstractSqlParameterSource
- java.lang.Object
- org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
- All Implemented Interfaces:
SqlParameterSource
- Direct Known Subclasses:
BeanPropertySqlParameterSource
,MapSqlParameterSource
public abstract class AbstractSqlParameterSource extends Object implements SqlParameterSource
Abstract base class forSqlParameterSource
implementations. Provides registration of SQL types per parameter and a friendlytoString
representation enumerating all parameters for aSqlParameterSource
implementingSqlParameterSource.getParameterNames()
. Concrete subclasses must implementSqlParameterSource.hasValue(java.lang.String)
andSqlParameterSource.getValue(java.lang.String)
.- Since:
- 2.0
- Author:
- Juergen Hoeller, Jens Schauder
- See Also:
SqlParameterSource.hasValue(String)
,SqlParameterSource.getValue(String)
,SqlParameterSource.getParameterNames()
Field Summary
Fields inherited from interface org.springframework.jdbc.core.namedparam.SqlParameterSource
TYPE_UNKNOWN
Constructor Summary
Constructors Constructor Description AbstractSqlParameterSource()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getSqlType(String paramName)
Return the SQL type for the given parameter, if registered.String
getTypeName(String paramName)
Return the type name for the given parameter, if registered.void
registerSqlType(String paramName, int sqlType)
Register an SQL type for the given parameter.void
registerTypeName(String paramName, String typeName)
Register an SQL type for the given parameter.String
toString()
Enumerate the parameter names and values with their corresponding SQL type if available, or just return the simpleSqlParameterSource
implementation class name otherwise.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.jdbc.core.namedparam.SqlParameterSource
getParameterNames, getValue, hasValue
Constructor Detail
AbstractSqlParameterSource
public AbstractSqlParameterSource()
Method Detail
registerSqlType
public void registerSqlType(String paramName, int sqlType)
Register an SQL type for the given parameter.- Parameters:
paramName
- the name of the parametersqlType
- the SQL type of the parameter
registerTypeName
public void registerTypeName(String paramName, String typeName)
Register an SQL type for the given parameter.- Parameters:
paramName
- the name of the parametertypeName
- the type name of the parameter
getSqlType
public int getSqlType(String paramName)
Return the SQL type for the given parameter, if registered.- Specified by:
getSqlType
in interfaceSqlParameterSource
- Parameters:
paramName
- the name of the parameter- Returns:
- the SQL type of the parameter, or
TYPE_UNKNOWN
if not registered - See Also:
SqlParameterSource.TYPE_UNKNOWN
getTypeName
@Nullable public String getTypeName(String paramName)
Return the type name for the given parameter, if registered.- Specified by:
getTypeName
in interfaceSqlParameterSource
- Parameters:
paramName
- the name of the parameter- Returns:
- the type name of the parameter, or
null
if not registered
toString
public String toString()
Enumerate the parameter names and values with their corresponding SQL type if available, or just return the simpleSqlParameterSource
implementation class name otherwise.- Overrides:
toString
in classObject
- Since:
- 5.2
- See Also:
SqlParameterSource.getParameterNames()