Class MappingR2dbcConverter

java.lang.Object
org.springframework.data.relational.core.conversion.BasicRelationalConverter
org.springframework.data.r2dbc.convert.MappingR2dbcConverter
All Implemented Interfaces:
org.springframework.data.convert.EntityReader<Object,io.r2dbc.spi.Row>, org.springframework.data.convert.EntityWriter<Object,OutboundRow>, R2dbcConverter, RelationalConverter

public class MappingR2dbcConverter extends BasicRelationalConverter implements R2dbcConverter
Converter for R2DBC.
Author:
Mark Paluch, Oliver Drotbohm
  • Constructor Details

  • Method Details

    • read

      public <R> R read(Class<R> type, io.r2dbc.spi.Row row)
      Specified by:
      read in interface org.springframework.data.convert.EntityReader<Object,io.r2dbc.spi.Row>
    • read

      public <R> R read(Class<R> type, io.r2dbc.spi.Row row, @Nullable io.r2dbc.spi.RowMetadata metadata)
      Description copied from interface: R2dbcConverter
      Reads the given source into the given type.
      Specified by:
      read in interface R2dbcConverter
      Parameters:
      type - they type to convert the given source to.
      row - the source to create an object of the given type from.
      metadata - the RowMetadata.
      Returns:
    • readValue

      public Object readValue(@Nullable Object value, org.springframework.data.util.TypeInformation<?> type)
      Description copied from interface: RelationalConverter
      Read a relational value into the desired destination type.
      Specified by:
      readValue in interface RelationalConverter
      Overrides:
      readValue in class BasicRelationalConverter
      Parameters:
      value - a value as it is returned by the driver accessing the persistence store. May be null.
      type - TypeInformation into which the value is to be converted. Must not be null.
      Returns:
      The converted value. May be null.
    • write

      public void write(Object source, OutboundRow sink)
      Specified by:
      write in interface org.springframework.data.convert.EntityWriter<Object,OutboundRow>
    • createCollection

      protected List<Object> createCollection(Collection<?> collection, RelationalPersistentProperty property)
      Writes the given Collection using the given RelationalPersistentProperty information.
      Parameters:
      collection - must not be null.
      property - must not be null.
      Returns:
    • getArrayValue

      public Object getArrayValue(ArrayColumns arrayColumns, RelationalPersistentProperty property, Object value)
      Description copied from interface: R2dbcConverter
      Convert a value into an array representation according to ArrayColumns.
      Specified by:
      getArrayValue in interface R2dbcConverter
      Parameters:
      arrayColumns - dialect-specific array handling configuration.
      Returns:
    • getTargetType

      public Class<?> getTargetType(Class<?> valueType)
      Description copied from interface: R2dbcConverter
      Return the target type for a value considering registered converters.
      Specified by:
      getTargetType in interface R2dbcConverter
      Parameters:
      valueType - must not be null.
      Returns:
    • isSimpleType

      public boolean isSimpleType(Class<?> type)
      Description copied from interface: R2dbcConverter
      Return whether the type is a simple type. Simple types are database primitives or types with a custom mapping strategy.
      Specified by:
      isSimpleType in interface R2dbcConverter
      Parameters:
      type - the type to inspect, must not be null.
      Returns:
      true if the type is a simple one.
      See Also:
      • SimpleTypeHolder
    • populateIdIfNecessary

      public <T> BiFunction<io.r2dbc.spi.Row,io.r2dbc.spi.RowMetadata,T> populateIdIfNecessary(T object)
      Returns a Function that populates the id property of the object from a Row.
      Specified by:
      populateIdIfNecessary in interface R2dbcConverter
      Parameters:
      object - must not be null.
      Returns: