Package org.springframework.jdbc.core.namedparam

# Class SimplePropertySqlParameterSource

java.lang.Object
org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource
org.springframework.jdbc.core.namedparam.SimplePropertySqlParameterSource

All Implemented Interfaces:
  `SqlParameterSource`

public class SimplePropertySqlParameterSource extends AbstractSqlParameterSource
`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:
  - `NamedParameterJdbcTemplate`
  - `BeanPropertySqlParameterSource`
  - `JdbcClient.StatementSpec.paramSource(Object)`
  - `SimplePropertyRowMapper`

## Field Summary

### Fields inherited from interface org.springframework.jdbc.core.namedparam.SqlParameterSource

`TYPE_UNKNOWN`

## Constructor Summary

Constructors
Constructor
Description
`SimplePropertySqlParameterSource(Object paramObject)`
Create a new SqlParameterSource for the given bean, record or field holder.

## Method Summary

Modifier and Type
Method
Description
`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.

### 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

public SimplePropertySqlParameterSource(Object paramObject)
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

public boolean hasValue(String paramName)
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

@Nullable public Object getValue(String paramName) throws IllegalArgumentException
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

public int getSqlType(String paramName)
Derives a default SQL type from the corresponding property type.

Specified by:
  `getSqlType` in interface `SqlParameterSource`
Overrides:
  `getSqlType` in class `AbstractSqlParameterSource`
Parameters:
  `paramName` - the name of the parameter
Returns:
  the SQL type of the parameter, or `TYPE_UNKNOWN` if not registered
See Also:
  - `StatementCreatorUtils.javaTypeToSqlParameterType(java.lang.Class<?>)`