Class SimplePropertySqlParameterSource
java.lang.Object
org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
org.springframework.jdbc.core.namedparam.SimplePropertySqlParameterSource
- All Implemented Interfaces:
SqlParameterSource
SqlParameterSource
implementation that obtains parameter values
from bean properties of a given JavaBean object, from component accessors
of a record class, or from raw field access.
This is a more flexible variant of BeanPropertySqlParameterSource
,
with the limitation that it is not able to enumerate its
parameter names
.
In terms of its fallback property discovery algorithm, this class is
similar to SimpleErrors
which is
also just used for property retrieval purposes (rather than binding).
- Since:
- 6.1
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.jdbc.core.namedparam.SqlParameterSource
TYPE_UNKNOWN
-
Constructor Summary
ConstructorDescriptionSimplePropertySqlParameterSource
(Object paramObject) Create a new SqlParameterSource for the given bean, record or field holder. -
Method Summary
Modifier and TypeMethodDescriptionint
getSqlType
(String paramName) Derives a default SQL type from the corresponding property type.Return the parameter value for the requested named parameter.boolean
Determine whether there is a value for the specified named parameter.Methods inherited from class org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
getTypeName, registerSqlType, registerTypeName, toString
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
-
Constructor Details
-
SimplePropertySqlParameterSource
Create a new SqlParameterSource for the given bean, record or field holder.- Parameters:
paramObject
- the bean, record or field holder instance to wrap
-
-
Method Details
-
hasValue
Description copied from interface:SqlParameterSource
Determine whether there is a value for the specified named parameter.- Parameters:
paramName
- the name of the parameter- Returns:
- whether there is a value defined
-
getValue
Description copied from interface:SqlParameterSource
Return the parameter value for the requested named parameter.- Parameters:
paramName
- the name of the parameter- Returns:
- the value of the specified parameter
- Throws:
IllegalArgumentException
- if there is no value for the requested parameter
-
getSqlType
Derives a default SQL type from the corresponding property type.- Specified by:
getSqlType
in interfaceSqlParameterSource
- Overrides:
getSqlType
in classAbstractSqlParameterSource
- Parameters:
paramName
- the name of the parameter- Returns:
- the SQL type of the parameter,
or
TYPE_UNKNOWN
if not registered - See Also:
-