public class BeanPropertySqlParameterSource extends AbstractSqlParameterSource
SqlParameterSource
implementation that obtains parameter values
from bean properties of a given JavaBean object. The names of the bean
properties have to match the parameter names.
Uses a Spring BeanWrapper for bean property access underneath.
NamedParameterJdbcTemplate
,
BeanWrapper
TYPE_UNKNOWN
Constructor and Description |
---|
BeanPropertySqlParameterSource(Object object)
Create a new BeanPropertySqlParameterSource for the given bean.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getParameterNames()
Enumerate all available parameter names if possible.
|
String[] |
getReadablePropertyNames()
Provide access to the property names of the wrapped bean.
|
int |
getSqlType(String paramName)
Derives a default SQL type from the corresponding property type.
|
Object |
getValue(String paramName)
Return the parameter value for the requested named parameter.
|
boolean |
hasValue(String paramName)
Determine whether there is a value for the specified named parameter.
|
getTypeName, registerSqlType, registerTypeName, toString
public BeanPropertySqlParameterSource(Object object)
object
- the bean instance to wrappublic boolean hasValue(String paramName)
SqlParameterSource
paramName
- the name of the parameter@Nullable public Object getValue(String paramName) throws IllegalArgumentException
SqlParameterSource
paramName
- the name of the parameterIllegalArgumentException
- if there is no value for the requested parameterpublic int getSqlType(String paramName)
getSqlType
in interface SqlParameterSource
getSqlType
in class AbstractSqlParameterSource
paramName
- the name of the parameterTYPE_UNKNOWN
if not registeredStatementCreatorUtils.javaTypeToSqlParameterType(java.lang.Class<?>)
@NonNull public String[] getParameterNames()
SqlParameterSource
This is an optional operation, primarily for use with
SimpleJdbcInsert
and SimpleJdbcCall
.
null
if not determinableSqlParameterSourceUtils.extractCaseInsensitiveParameterNames(org.springframework.jdbc.core.namedparam.SqlParameterSource)
public String[] getReadablePropertyNames()
PropertyAccessor
interface.