org.springframework.data.jdbc.core.convert

## Class BasicJdbcConverter

- java.lang.Object
- - org.springframework.data.relational.core.conversion.BasicRelationalConverter
  - - org.springframework.data.jdbc.core.convert.BasicJdbcConverter

All Implemented Interfaces:
  Aware, ApplicationContextAware, JdbcConverter, RelationalConverter

    public class BasicJdbcConverter
    extends BasicRelationalConverter
    implements JdbcConverter, ApplicationContextAware

`RelationalConverter` that uses a `MappingContext` to apply basic conversion of relational values to property values.

Conversion is configurable by providing a customized `CustomConversions`.

Since:
  1.1
Author:
  Mark Paluch, Jens Schauder, Christoph Strobl, Myeonghyeon Lee
See Also:
  `MappingContext`, `SimpleTypeHolder`, `CustomConversions`

### Constructor Summary

Constructors
Constructor and Description
`BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context, RelationResolver relationResolver)` Creates a new `BasicRelationalConverter` given `MappingContext` and a `no-op type factory` throwing `UnsupportedOperationException` on type creation.
`BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context, RelationResolver relationResolver, CustomConversions conversions, JdbcTypeFactory typeFactory, IdentifierProcessing identifierProcessing)` Creates a new `BasicRelationalConverter` given `MappingContext`.

### Method Summary

All Methods Instance Methods Concrete Methods
`Class<?>` `getColumnType(RelationalPersistentProperty property)` The type to be used to store this property in the database.
`int` `getSqlType(RelationalPersistentProperty property)` The SQL type constant used when using this property as a parameter for a SQL statement.
`<T> T` `mapRow(PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key)` Read the current row from `ResultSet` to an `entity`.
`<T> T` `mapRow(RelationalPersistentEntity<T> entity, ResultSet resultSet, Object key)` Read the current row from `ResultSet` to an `entity`.
`Object` `readValue(Object value, TypeInformation<?> type)`
`void` `setApplicationContext(ApplicationContext applicationContext)`
`JdbcValue` `writeJdbcValue(Object value, Class<?> columnType, int sqlType)` Convert a property value into a `JdbcValue` that contains the converted value and information how to bind it to JDBC parameters.
`Object` `writeValue(Object value, TypeInformation<?> type)`

### Methods inherited from class org.springframework.data.relational.core.conversion.BasicRelationalConverter

`createInstance, getConversions, getConversionService, getMappingContext, getPropertyAccessor`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.data.relational.core.conversion.RelationalConverter

`createInstance, getConversionService, getMappingContext, getPropertyAccessor`

### Constructor Detail

#### BasicJdbcConverter

    public BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context,
                              RelationResolver relationResolver)

Creates a new `BasicRelationalConverter` given `MappingContext` and a `no-op type factory` throwing `UnsupportedOperationException` on type creation. Use `BasicJdbcConverter(MappingContext, RelationResolver, CustomConversions, JdbcTypeFactory, IdentifierProcessing)` (MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types.

Parameters:
  `context` - must not be null.
  `relationResolver` - used to fetch additional relations from the database. Must not be null.

#### BasicJdbcConverter

    public BasicJdbcConverter(MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> context,
                              RelationResolver relationResolver,
                              CustomConversions conversions,
                              JdbcTypeFactory typeFactory,
                              IdentifierProcessing identifierProcessing)

Creates a new `BasicRelationalConverter` given `MappingContext`.

Parameters:
  `context` - must not be null.
  `relationResolver` - used to fetch additional relations from the database. Must not be null.
  `typeFactory` - must not be null
  `identifierProcessing` - must not be null
Since:
  2.0

### Method Detail

#### setApplicationContext

    public void setApplicationContext(ApplicationContext applicationContext)

Specified by:
  `setApplicationContext` in interface `ApplicationContextAware`

#### getSqlType

    public int getSqlType(RelationalPersistentProperty property)

Description copied from interface: `JdbcConverter`
The SQL type constant used when using this property as a parameter for a SQL statement.

Specified by:
  `getSqlType` in interface `JdbcConverter`
Returns:
  Must not be `null`.
See Also:
  `Types`

#### getColumnType

    public Class<?> getColumnType(RelationalPersistentProperty property)

Description copied from interface: `JdbcConverter`
The type to be used to store this property in the database. Multidimensional arrays are unwrapped to reflect a top-level array type (e.g. `String[][]` returns `String[]`).

Specified by:
  `getColumnType` in interface `JdbcConverter`
Returns:
  a `Class` that is suitable for usage with JDBC drivers.
See Also:
  `JdbcUtil.sqlTypeFor(Class)`

#### readValue

    @Nullable
    public Object readValue(@Nullable
                                      Object value,
                                      TypeInformation<?> type)

Specified by:
  `readValue` in interface `RelationalConverter`
Overrides:
  `readValue` in class `BasicRelationalConverter`

#### writeValue

    @Nullable
    public Object writeValue(@Nullable
                                       Object value,
                                       TypeInformation<?> type)

Specified by:
  `writeValue` in interface `RelationalConverter`
Overrides:
  `writeValue` in class `BasicRelationalConverter`

#### writeJdbcValue

    public JdbcValue writeJdbcValue(@Nullable
                                    Object value,
                                    Class<?> columnType,
                                    int sqlType)

Description copied from interface: `JdbcConverter`
Convert a property value into a `JdbcValue` that contains the converted value and information how to bind it to JDBC parameters.

Specified by:
  `writeJdbcValue` in interface `JdbcConverter`
Parameters:
  `value` - a value as it is used in the object model. May be `null`.
  `columnType` - `TypeInformation` into which the value is to be converted. Must not be `null`.
  `sqlType` - the type constant from `Types` to be used if non is specified by a converter.
Returns:
  The converted value wrapped in a `JdbcValue`. Guaranteed to be not null.

#### mapRow

    public <T> T mapRow(RelationalPersistentEntity<T> entity,
                        ResultSet resultSet,
                        Object key)

Description copied from interface: `JdbcConverter`
Read the current row from `ResultSet` to an `entity`.

Specified by:
  `mapRow` in interface `JdbcConverter`
Parameters:
  `entity` - the persistent entity type.
  `resultSet` - the `ResultSet` to read from.
  `key` - primary key.
Returns:

#### mapRow

    public <T> T mapRow(PersistentPropertyPathExtension path,
                        ResultSet resultSet,
                        Identifier identifier,
                        Object key)

Description copied from interface: `JdbcConverter`
Read the current row from `ResultSet` to an `entity`.

Specified by:
  `mapRow` in interface `JdbcConverter`
Parameters:
  `path` - path to the owning property.
  `resultSet` - the `ResultSet` to read from.
  `identifier` - entity identifier.
  `key` - primary key.
Returns: