Interface JdbcConverter

All Superinterfaces:
org.springframework.data.relational.core.conversion.RelationalConverter
All Known Implementing Classes:
BasicJdbcConverter, MappingJdbcConverter

public interface JdbcConverter extends org.springframework.data.relational.core.conversion.RelationalConverter
A JdbcConverter is responsible for converting for values to the native relational representation and vice versa.
Since:
1.1
Author:
Jens Schauder, Mark Paluch
  • Method Summary

    Modifier and Type
    Method
    Description
    getColumnType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property)
    The type to be used to store this property in the database.
    org.springframework.data.relational.core.mapping.RelationalMappingContext
     
    getTargetSqlType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property)
    The SQL type constant used when using this property as a parameter for a SQL statement.
    default <T> T
    mapRow(org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key)
    Deprecated, for removal: This API element is subject to removal in a future version.
    default <T> T
    mapRow(org.springframework.data.relational.core.mapping.RelationalPersistentEntity<T> entity, ResultSet resultSet, Object key)
    Deprecated.
    default <R> R
    readAndResolve(Class<R> type, org.springframework.data.relational.domain.RowDocument source)
    Read a RowDocument into the requested aggregate type and resolve references by looking these up from RelationResolver.
    default <R> R
    readAndResolve(Class<R> type, org.springframework.data.relational.domain.RowDocument source, Identifier identifier)
    Read a RowDocument into the requested aggregate type and resolve references by looking these up from RelationResolver.
    <R> R
    readAndResolve(TypeInformation<R> type, org.springframework.data.relational.domain.RowDocument source, Identifier identifier)
    Read a RowDocument into the requested aggregate type and resolve references by looking these up from RelationResolver.
    default JdbcValue
    writeJdbcValue(Object value, Class<?> type, SQLType sqlType)
    Convert a property value into a JdbcValue that contains the converted value and information how to bind it to JDBC parameters.
    writeJdbcValue(Object value, TypeInformation<?> type, SQLType sqlType)
    Convert a property value into a JdbcValue that contains the converted value and information how to bind it to JDBC parameters.

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

    createInstance, getConversionService, getEntityInstantiators, getPropertyAccessor, introspectProjection, project, read, readValue, writeValue
  • Method Details

    • writeJdbcValue

      default JdbcValue writeJdbcValue(@Nullable Object value, Class<?> type, SQLType sqlType)
      Convert a property value into a JdbcValue that contains the converted value and information how to bind it to JDBC parameters.
      Parameters:
      value - a value as it is used in the object model. May be null.
      type - Class into which the value is to be converted. Must not be null.
      sqlType - the SQLType to be used if non is specified by a converter.
      Returns:
      The converted value wrapped in a JdbcValue. Guaranteed to be not null.
      Since:
      2.4
    • writeJdbcValue

      JdbcValue writeJdbcValue(@Nullable Object value, TypeInformation<?> type, SQLType sqlType)
      Convert a property value into a JdbcValue that contains the converted value and information how to bind it to JDBC parameters.
      Parameters:
      value - a value as it is used in the object model. May be null.
      type - TypeInformation into which the value is to be converted. Must not be null.
      sqlType - the SQLType to be used if non is specified by a converter.
      Returns:
      The converted value wrapped in a JdbcValue. Guaranteed to be not null.
      Since:
      3.2.6
    • mapRow

      @Deprecated(since="3.2") default <T> T mapRow(org.springframework.data.relational.core.mapping.RelationalPersistentEntity<T> entity, ResultSet resultSet, Object key)
      Deprecated.
      Read the current row from ResultSet to an entity.
      Type Parameters:
      T -
      Parameters:
      entity - the persistent entity type.
      resultSet - the ResultSet to read from.
      key - primary key.
      Returns:
    • mapRow

      @Deprecated(since="3.2", forRemoval=true) default <T> T mapRow(org.springframework.data.relational.core.mapping.PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Read the current row from ResultSet to an entity.
      Type Parameters:
      T -
      Parameters:
      path - path to the owning property.
      resultSet - the ResultSet to read from.
      identifier - entity identifier.
      key - primary key.
      Returns:
    • readAndResolve

      default <R> R readAndResolve(Class<R> type, org.springframework.data.relational.domain.RowDocument source)
      Read a RowDocument into the requested aggregate type and resolve references by looking these up from RelationResolver.
      Type Parameters:
      R - aggregate type.
      Parameters:
      type - target aggregate type.
      source - source RowDocument.
      Returns:
      the converted object.
      Since:
      3.2
      See Also:
      • RelationalConverter.read(Class, RowDocument)
    • readAndResolve

      default <R> R readAndResolve(Class<R> type, org.springframework.data.relational.domain.RowDocument source, Identifier identifier)
      Read a RowDocument into the requested aggregate type and resolve references by looking these up from RelationResolver.
      Type Parameters:
      R - aggregate type.
      Parameters:
      type - target aggregate type.
      source - source RowDocument.
      identifier - identifier chain.
      Returns:
      the converted object.
      Since:
      3.2
      See Also:
      • RelationalConverter.read(Class, RowDocument)
    • readAndResolve

      <R> R readAndResolve(TypeInformation<R> type, org.springframework.data.relational.domain.RowDocument source, Identifier identifier)
      Read a RowDocument into the requested aggregate type and resolve references by looking these up from RelationResolver.
      Type Parameters:
      R - aggregate type.
      Parameters:
      type - target aggregate type.
      source - source RowDocument.
      identifier - identifier chain.
      Returns:
      the converted object.
      Since:
      3.2.6
      See Also:
      • RelationalConverter.read(Class, RowDocument)
    • getColumnType

      Class<?> getColumnType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property)
      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[]).
      Returns:
      a Class that is suitable for usage with JDBC drivers.
      Since:
      2.0 TODO: Introduce variant returning TypeInformation.
      See Also:
    • getTargetSqlType

      SQLType getTargetSqlType(org.springframework.data.relational.core.mapping.RelationalPersistentProperty property)
      The SQL type constant used when using this property as a parameter for a SQL statement.
      Returns:
      Must not be null.
      Since:
      2.0
      See Also:
    • getMappingContext

      org.springframework.data.relational.core.mapping.RelationalMappingContext getMappingContext()
      Specified by:
      getMappingContext in interface org.springframework.data.relational.core.conversion.RelationalConverter