public class ConverterAwareMappingSpannerEntityProcessor extends Object implements SpannerEntityProcessor
Constructor and Description |
---|
ConverterAwareMappingSpannerEntityProcessor(SpannerMappingContext spannerMappingContext) |
ConverterAwareMappingSpannerEntityProcessor(SpannerMappingContext spannerMappingContext,
Collection<org.springframework.core.convert.converter.Converter> writeConverters,
Collection<org.springframework.core.convert.converter.Converter> readConverters) |
Modifier and Type | Method and Description |
---|---|
Key |
convertToKey(Object key)
Convert a given object to a Cloud Spanner key.
|
Class<?> |
getCorrespondingSpannerJavaType(Class originalType,
boolean isIterableInnerType)
Gets the type that will work for both read and writes with Spanner directly.
|
SpannerReadConverter |
getReadConverter()
Get the read converter used by this processor.
|
SpannerWriteConverter |
getSpannerWriteConverter()
Get the SpannerWriteConverter used to convert types into Cloud Spanner compatible
types.
|
SpannerWriteConverter |
getWriteConverter()
Get the write converter used by this processor.
|
<T> List<T> |
mapToList(ResultSet resultSet,
Class<T> entityClass)
Converts a set of Spanner
ResultSet into a list of objects. |
<T> List<T> |
mapToList(ResultSet resultSet,
Class<T> entityClass,
Set<String> includeColumns,
boolean allowMissingColumns)
Converts a Spanner
ResultSet into a list of objects. |
<T> List<T> |
mapToList(ResultSet resultSet,
Class<T> entityClass,
String... includeColumns)
Converts a set of Spanner
ResultSet into a list of objects. |
default <R> R |
read(Class<R> type,
Struct source) |
<R> R |
read(Class<R> type,
Struct source,
Set<String> includeColumns,
boolean allowMissingColumns) |
void |
write(Object source,
MultipleValueBinder sink)
Writes each of the source properties to the sink.
|
void |
write(Object source,
MultipleValueBinder sink,
Set<String> includeColumns)
Writes an object's properties to the sink.
|
public ConverterAwareMappingSpannerEntityProcessor(SpannerMappingContext spannerMappingContext)
public ConverterAwareMappingSpannerEntityProcessor(SpannerMappingContext spannerMappingContext, Collection<org.springframework.core.convert.converter.Converter> writeConverters, Collection<org.springframework.core.convert.converter.Converter> readConverters)
public <T> List<T> mapToList(ResultSet resultSet, Class<T> entityClass)
SpannerEntityProcessor
ResultSet
into a list of objects.mapToList
in interface SpannerEntityProcessor
T
- the type of the objects the Spanner results represent.resultSet
- the Spanner results to convert. The ResultSet will be exhausted and
closed.entityClass
- the type of the objects the Spanner results represent.public <T> List<T> mapToList(ResultSet resultSet, Class<T> entityClass, Set<String> includeColumns, boolean allowMissingColumns)
SpannerEntityProcessor
ResultSet
into a list of objects.mapToList
in interface SpannerEntityProcessor
T
- the type of the objects the Spanner results represent.resultSet
- the Spanner results to convert. The ResultSet will be exhausted
and closed.entityClass
- the type of the objects the Spanner results represent.includeColumns
- the Set of columns to read. If this param is null then all
columns will be read.allowMissingColumns
- if true, then properties with no corresponding column
are not mapped. If false, then an exception is thrown.public <T> List<T> mapToList(ResultSet resultSet, Class<T> entityClass, String... includeColumns)
SpannerEntityProcessor
ResultSet
into a list of objects.mapToList
in interface SpannerEntityProcessor
T
- the type of the objects the Spanner results represent.resultSet
- the Spanner results to convert. The ResultSet will be exhausted and
closed.entityClass
- the type of the objects the Spanner results represent.includeColumns
- the columns to read. If none are provided then all columns are
read.public Class<?> getCorrespondingSpannerJavaType(Class originalType, boolean isIterableInnerType)
SpannerEntityProcessor
getCorrespondingSpannerJavaType
in interface SpannerEntityProcessor
originalType
- the original type that is possibly convertable by this converter.isIterableInnerType
- true if the given type refers to an inner type. This is
significant because Spanner does not support the same types as singular items and as
array elements.public void write(Object source, MultipleValueBinder sink)
write
in interface org.springframework.data.convert.EntityWriter<Object,MultipleValueBinder>
source
- entity to be writtensink
- the stateful multiple-value-binder as a target for writing.public void write(Object source, MultipleValueBinder sink, Set<String> includeColumns)
SpannerEntityWriter
write
in interface SpannerEntityWriter
source
- the object to writesink
- the sink to which to writeincludeColumns
- the properties/columns to write. If null, then all columns are
written.public Key convertToKey(Object key)
SpannerEntityWriter
convertToKey
in interface SpannerEntityWriter
key
- the object containing the key values. This can already be a Cloud Spanner
key, a single key component, or an array of key components.public SpannerWriteConverter getSpannerWriteConverter()
SpannerEntityWriter
getSpannerWriteConverter
in interface SpannerEntityWriter
public <R> R read(Class<R> type, Struct source, Set<String> includeColumns, boolean allowMissingColumns)
public SpannerWriteConverter getWriteConverter()
SpannerEntityProcessor
getWriteConverter
in interface SpannerEntityProcessor
public SpannerReadConverter getReadConverter()
SpannerEntityProcessor
getReadConverter
in interface SpannerEntityProcessor
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.