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

public Class SimplePropertySqlParameterSource

extends AbstractSqlParameterSource
Class Inheritance
Imports
java.beans.PropertyDescriptor, java.lang.reflect.Field, java.util.Map, java.util.concurrent.ConcurrentHashMap, org.springframework.beans.BeanUtils, org.springframework.jdbc.core.StatementCreatorUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .ReflectionUtils

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 org.springframework.validation.SimpleErrors which is also just used for property retrieval purposes (rather than binding).

Author
Juergen Hoeller
Since
6.1
See Also
NamedParameterJdbcTemplate, BeanPropertySqlParameterSource, org.springframework.jdbc.core.simple.JdbcClient.StatementSpec#paramSource(Object), org.springframework.jdbc.core.SimplePropertyRowMapper

Field Summary

Modifier and TypeField and Description
private static final Object
private final Object
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public
SimplePropertySqlParameterSource(Object
the bean, record or field holder instance to wrap
paramObject
)

Create a new SqlParameterSource for the given bean, record or field holder.

Method Summary

Modifier and TypeMethod and Description
private Object
getDescriptor(String paramName)

public int
getSqlType(String
the name of the parameter
paramName
)

Overrides org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource.getSqlType.

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

Derives a default SQL type from the corresponding property type.
public Object
getValue(String
the name of the parameter
paramName
)

Implements org.springframework.jdbc.core.namedparam.SqlParameterSource.getValue.

Return the parameter value for the requested named parameter.
public boolean
hasValue(String
the name of the parameter
paramName
)

Implements org.springframework.jdbc.core.namedparam.SqlParameterSource.hasValue.

Determine whether there is a value for the specified named parameter.
Inherited from org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource:
getTypeNameregisterSqlTyperegisterTypeNametoString

Field Detail

NO_DESCRIPTORback to summary
private static final Object NO_DESCRIPTOR
paramObjectback to summary
private final Object paramObject
propertyDescriptorsback to summary
private final Map<String, Object> propertyDescriptors

Constructor Detail

SimplePropertySqlParameterSourceback to summary
public SimplePropertySqlParameterSource(Object paramObject)

Create a new SqlParameterSource for the given bean, record or field holder.

Parameters
paramObject:Object

the bean, record or field holder instance to wrap

Method Detail

getDescriptorback to summary
private Object getDescriptor(String paramName)
getSqlTypeback to summary
public int getSqlType(String paramName)

Overrides org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource.getSqlType.

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

Derives a default SQL type from the corresponding property type.

Parameters
paramName:String

Doc from org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource.getSqlType.

the name of the parameter

Returns:int

Doc from org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource.getSqlType.

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

Annotations
@Override
See Also
StatementCreatorUtils#javaTypeToSqlParameterType
getValueback to summary
public Object getValue(String paramName) throws IllegalArgumentException

Implements org.springframework.jdbc.core.namedparam.SqlParameterSource.getValue.

Doc from org.springframework.jdbc.core.namedparam.SqlParameterSource.getValue.

Return the parameter value for the requested named parameter.

Parameters
paramName:String

the name of the parameter

Returns:Object

the value of the specified parameter

Annotations
@Override
@Nullable
Exceptions
IllegalArgumentException:
if there is no value for the requested parameter
hasValueback to summary
public boolean hasValue(String paramName)

Implements org.springframework.jdbc.core.namedparam.SqlParameterSource.hasValue.

Doc from org.springframework.jdbc.core.namedparam.SqlParameterSource.hasValue.

Determine whether there is a value for the specified named parameter.

Parameters
paramName:String

the name of the parameter

Returns:boolean

whether there is a value defined

Annotations
@Override