Class MappingR2dbcConverter

java.lang.Object
org.springframework.data.relational.core.conversion.AbstractRelationalConverter
org.springframework.data.relational.core.conversion.MappingRelationalConverter
org.springframework.data.r2dbc.convert.MappingR2dbcConverter
All Implemented Interfaces:
Aware, ApplicationContextAware, EnvironmentCapable, EntityReader<Object,Row>, EntityWriter<Object,OutboundRow>, R2dbcConverter, org.springframework.data.relational.core.conversion.RelationalConverter

public class MappingR2dbcConverter extends org.springframework.data.relational.core.conversion.MappingRelationalConverter implements R2dbcConverter
Converter for R2DBC.
Author:
Mark Paluch, Oliver Drotbohm
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.data.relational.core.conversion.MappingRelationalConverter

    org.springframework.data.relational.core.conversion.MappingRelationalConverter.AggregatePathValueProvider, org.springframework.data.relational.core.conversion.MappingRelationalConverter.ConversionContext, org.springframework.data.relational.core.conversion.MappingRelationalConverter.DefaultConversionContext, org.springframework.data.relational.core.conversion.MappingRelationalConverter.DocumentValueProvider, org.springframework.data.relational.core.conversion.MappingRelationalConverter.ProjectingConversionContext, org.springframework.data.relational.core.conversion.MappingRelationalConverter.RelationalPropertyValueProvider
  • Constructor Summary

    Constructors
    Constructor
    Description
    MappingR2dbcConverter(MappingContext<? extends org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> context)
    MappingR2dbcConverter(MappingContext<? extends org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> context, CustomConversions conversions)
  • Method Summary

    Modifier and Type
    Method
    Description
    protected List<Object>
    createCollection(Collection<?> collection, org.springframework.data.relational.core.mapping.RelationalPersistentProperty property)
    Writes the given Collection using the given RelationalPersistentProperty information.
    getArrayValue(org.springframework.data.relational.core.dialect.ArrayColumns arrayColumns, org.springframework.data.relational.core.mapping.RelationalPersistentProperty property, Object value)
    Convert a value into an array representation according to ArrayColumns.
    getTargetType(Class<?> valueType)
    Return the target type for a value considering registered converters.
    boolean
    Return whether the type is a simple type.
    Returns a Function that populates the id property of the object from a Row.
    <R> R
    read(Class<R> type, Row row)
     
    <R> R
    read(Class<R> type, Row row, RowMetadata metadata)
    Reads the given source into the given type.
    org.springframework.data.relational.domain.RowDocument
    toRowDocument(Class<?> type, Readable row, Iterable<? extends ReadableMetadata> metadata)
    Create a flat RowDocument from a single Row or Stored Procedure output.
    void
    write(Object source, OutboundRow sink)
     

    Methods inherited from class org.springframework.data.relational.core.conversion.MappingRelationalConverter

    createInstance, doReadProjection, getConversionContext, getEnvironment, getPotentiallyConvertedSimpleRead, getPropertyAccessor, introspectProjection, newProjectingConversionContext, newValueProvider, project, read, read, readAggregate, readAggregate, readCollectionOrArray, readMap, readValue, setApplicationContext, writeValue

    Methods inherited from class org.springframework.data.relational.core.conversion.AbstractRelationalConverter

    getConversions, getConversionService, getEntityInstantiators, getMappingContext

    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.r2dbc.convert.R2dbcConverter

    getConversionService

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

    createInstance, getEntityInstantiators, getMappingContext, getPropertyAccessor, introspectProjection, project, read, readValue, writeValue
  • Constructor Details

    • MappingR2dbcConverter

      public MappingR2dbcConverter(MappingContext<? extends org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> context)
      Parameters:
      context - must not be null.
    • MappingR2dbcConverter

      public MappingR2dbcConverter(MappingContext<? extends org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> context, CustomConversions conversions)
      Parameters:
      context - must not be null.
  • Method Details

    • read

      public <R> R read(Class<R> type, Row row)
      Specified by:
      read in interface EntityReader<Object,Row>
    • read

      public <R> R read(Class<R> type, Row row, @Nullable 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:
    • toRowDocument

      public org.springframework.data.relational.domain.RowDocument toRowDocument(Class<?> type, Readable row, @Nullable Iterable<? extends ReadableMetadata> metadata)
      Description copied from interface: R2dbcConverter
      Create a flat RowDocument from a single Row or Stored Procedure output.
      Specified by:
      toRowDocument in interface R2dbcConverter
      Parameters:
      type - the underlying entity type.
      row - the row or stored procedure output to retrieve data from.
      metadata - readable metadata.
      Returns:
      the RowDocument containing the data.
    • write

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

      protected List<Object> createCollection(Collection<?> collection, org.springframework.data.relational.core.mapping.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(org.springframework.data.relational.core.dialect.ArrayColumns arrayColumns, org.springframework.data.relational.core.mapping.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:
    • populateIdIfNecessary

      public <T> BiFunction<Row,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: