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
,EntityReader<Object,
,io.r2dbc.spi.Row> EntityWriter<Object,
,OutboundRow> R2dbcConverter
,RelationalConverter
Converter for R2DBC.
- Author:
- Mark Paluch, Oliver Drotbohm
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.data.relational.core.conversion.MappingRelationalConverter
MappingRelationalConverter.AggregatePathValueProvider, MappingRelationalConverter.ConversionContext, MappingRelationalConverter.DefaultConversionContext, MappingRelationalConverter.DocumentValueProvider, MappingRelationalConverter.ProjectingConversionContext, MappingRelationalConverter.RelationalPropertyValueProvider
-
Constructor Summary
ConstructorDescriptionMappingR2dbcConverter
(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context) Creates a newMappingR2dbcConverter
givenMappingContext
.MappingR2dbcConverter
(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, CustomConversions conversions) -
Method Summary
Modifier and TypeMethodDescriptioncreateCollection
(Collection<?> collection, RelationalPersistentProperty property) Writes the givenCollection
using the givenRelationalPersistentProperty
information.getArrayValue
(ArrayColumns arrayColumns, RelationalPersistentProperty property, Object value) Convert avalue
into an array representation according toArrayColumns
.Class<?>
getTargetType
(Class<?> valueType) Return the target type for a value considering registered converters.boolean
isSimpleType
(Class<?> type) Return whether thetype
is a simple type.<T> BiFunction<io.r2dbc.spi.Row,
io.r2dbc.spi.RowMetadata, T> populateIdIfNecessary
(T object) <R> R
<R> R
Reads the given source into the given type.toRowDocument
(Class<?> type, io.r2dbc.spi.Readable row, Iterable<? extends io.r2dbc.spi.ReadableMetadata> metadata) Create a flatRowDocument
from a singleRow or Stored Procedure output
.void
write
(Object source, OutboundRow sink) Methods inherited from class org.springframework.data.relational.core.conversion.MappingRelationalConverter
createInstance, doReadProjection, getConversionContext, 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 RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context) Creates a newMappingR2dbcConverter
givenMappingContext
.- Parameters:
context
- must not be null.
-
MappingR2dbcConverter
public MappingR2dbcConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, CustomConversions conversions) - Parameters:
context
- must not be null.
-
-
Method Details
-
read
- Specified by:
read
in interfaceEntityReader<Object,
io.r2dbc.spi.Row>
-
read
Description copied from interface:R2dbcConverter
Reads the given source into the given type.- Specified by:
read
in interfaceR2dbcConverter
- Parameters:
type
- they type to convert the given source to.row
- the source to create an object of the given type from.metadata
- theRowMetadata
.- Returns:
-
toRowDocument
public RowDocument toRowDocument(Class<?> type, io.r2dbc.spi.Readable row, @Nullable Iterable<? extends io.r2dbc.spi.ReadableMetadata> metadata) Description copied from interface:R2dbcConverter
Create a flatRowDocument
from a singleRow or Stored Procedure output
.- Specified by:
toRowDocument
in interfaceR2dbcConverter
- 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
- Specified by:
write
in interfaceEntityWriter<Object,
OutboundRow>
-
createCollection
protected List<Object> createCollection(Collection<?> collection, RelationalPersistentProperty property) Writes the givenCollection
using the givenRelationalPersistentProperty
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 avalue
into an array representation according toArrayColumns
.- Specified by:
getArrayValue
in interfaceR2dbcConverter
- Parameters:
arrayColumns
- dialect-specific array handling configuration.- Returns:
-
getTargetType
Description copied from interface:R2dbcConverter
Return the target type for a value considering registered converters.- Specified by:
getTargetType
in interfaceR2dbcConverter
- Parameters:
valueType
- must not be null.- Returns:
-
isSimpleType
Description copied from interface:R2dbcConverter
Return whether thetype
is a simple type. Simple types are database primitives or types with a custom mapping strategy.- Specified by:
isSimpleType
in interfaceR2dbcConverter
- Parameters:
type
- the type to inspect, must not be null.- Returns:
- true if the type is a simple one.
- See Also:
-
populateIdIfNecessary
- Specified by:
populateIdIfNecessary
in interfaceR2dbcConverter
- Parameters:
object
- must not be null.- Returns:
-