Top Description Fields Constructors Methods
org.springframework.jdbc.core.namedparam

public abstract Class AbstractSqlParameterSource

extends Object
implements SqlParameterSource
Class Inheritance
All Implemented Interfaces
org.springframework.jdbc.core.namedparam.SqlParameterSource
Known Direct Subclasses
org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource, org.springframework.jdbc.core.namedparam.MapSqlParameterSource, org.springframework.jdbc.core.namedparam.SimplePropertySqlParameterSource
Imports
java.util.HashMap, .Map, .StringJoiner, org.springframework.jdbc.core.SqlParameterValue, org.springframework.jdbc.support.JdbcUtils, org.springframework.lang.Nullable, org.springframework.util.Assert

Abstract base class for SqlParameterSource implementations. Provides registration of SQL types per parameter and a friendly toString representation enumerating all parameters for a SqlParameterSource implementing getParameterNames(). Concrete subclasses must implement hasValue and getValue.
Authors
Juergen Hoeller, Jens Schauder
Since
2.0
See Also
hasValue(String), getValue(String), getParameterNames()

Field Summary

Modifier and TypeField and Description
private final Map<String, Integer>
private final Map<String, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the SQL type of the parameter, or TYPE_UNKNOWN if not registered
getSqlType
(String
the name of the parameter
paramName
)

Overrides default org.springframework.jdbc.core.namedparam.SqlParameterSource.getSqlType.

Return the SQL type for the given parameter, if registered.

public String

Returns:

the type name of the parameter, or null if not registered
getTypeName
(String
the name of the parameter
paramName
)

Overrides default org.springframework.jdbc.core.namedparam.SqlParameterSource.getTypeName.

Return the type name for the given parameter, if registered.

public void
registerSqlType(String
the name of the parameter
paramName
,
int
the SQL type of the parameter
sqlType
)

Register an SQL type for the given parameter.

public void
registerTypeName(String
the name of the parameter
paramName
,
String
the type name of the parameter
typeName
)

Register an SQL type for the given parameter.

public String
toString()

Overrides java.lang.Object.toString.

Enumerate the parameter names and values with their corresponding SQL type if available, or just return the simple SqlParameterSource implementation class name otherwise.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

sqlTypesback to summary
private final Map<String, Integer> sqlTypes
typeNamesback to summary
private final Map<String, String> typeNames

Constructor Detail

AbstractSqlParameterSourceback to summary
public AbstractSqlParameterSource()

Method Detail

getSqlTypeback to summary
public int getSqlType(String paramName)

Overrides default org.springframework.jdbc.core.namedparam.SqlParameterSource.getSqlType.

Return the SQL type for the given parameter, if registered.

Parameters
paramName:String

the name of the parameter

Returns:int

the SQL type of the parameter, or TYPE_UNKNOWN if not registered

Annotations
@Override
getTypeNameback to summary
public String getTypeName(String paramName)

Overrides default org.springframework.jdbc.core.namedparam.SqlParameterSource.getTypeName.

Return the type name for the given parameter, if registered.

Parameters
paramName:String

the name of the parameter

Returns:String

the type name of the parameter, or null if not registered

Annotations
@Override
@Nullable
registerSqlTypeback to summary
public void registerSqlType(String paramName, int sqlType)

Register an SQL type for the given parameter.

Parameters
paramName:String

the name of the parameter

sqlType:int

the SQL type of the parameter

registerTypeNameback to summary
public void registerTypeName(String paramName, String typeName)

Register an SQL type for the given parameter.

Parameters
paramName:String

the name of the parameter

typeName:String

the type name of the parameter

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Enumerate the parameter names and values with their corresponding SQL type if available, or just return the simple SqlParameterSource implementation class name otherwise.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override
Since
5.2
See Also
getParameterNames()