Interface RelationalConverter
- All Known Subinterfaces:
JdbcConverter
,R2dbcConverter
- All Known Implementing Classes:
AbstractRelationalConverter
,BasicJdbcConverter
,BasicRelationalConverter
,MappingJdbcConverter
,MappingR2dbcConverter
,MappingRelationalConverter
public interface RelationalConverter
A
RelationalConverter
is responsible for converting for values to the native relational representation and
vice versa.- Author:
- Mark Paluch, Jens Schauder
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> T
createInstance
(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) Deprecated.Returns the underlyingConversionService
used by the converter.Return the underlyingEntityInstantiators
.MappingContext<? extends RelationalPersistentEntity<?>,
? extends RelationalPersistentProperty> Returns the underlyingMappingContext
used by the converter.getPropertyAccessor
(PersistentEntity<T, ?> persistentEntity, T instance) Return aPersistentPropertyAccessor
to access property values of theinstance
.<M,
D> EntityProjection<M, D> introspectProjection
(Class<M> resultType, Class<D> entityType) Introspect the givenresult type
in the context of theentity type
whether the returned type is a projection and what property paths are participating in the projection.<R> R
project
(EntityProjection<R, ?> descriptor, RowDocument document) Apply a projection toRowDocument
and return the projection return typeR
.<R> R
read
(Class<R> type, RowDocument source) Read aRowDocument
into the requestedaggregate type
.readValue
(Object value, TypeInformation<?> type) Read a relational value into the desireddestination type
.writeValue
(Object value, TypeInformation<?> type) Write a property value into a relational type that can be stored natively.
-
Method Details
-
getConversionService
ConversionService getConversionService()Returns the underlyingConversionService
used by the converter.- Returns:
- never null.
-
getEntityInstantiators
EntityInstantiators getEntityInstantiators()Return the underlyingEntityInstantiators
.- Since:
- 2.3
-
getMappingContext
MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> getMappingContext()Returns the underlyingMappingContext
used by the converter.- Returns:
- never null
-
createInstance
@Deprecated(since="3.2") default <T> T createInstance(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) Deprecated.since 3.2, useread(java.lang.Class<R>, org.springframework.data.relational.domain.RowDocument)
method instead.Create a new instance ofPersistentEntity
givenParameterValueProvider
to obtain constructor properties.- Type Parameters:
T
- the type of entity to create.- Parameters:
entity
- the kind of entity to create. Must not benull
.parameterValueProvider
- a function that provides the value to pass to a constructor, given aParameter
. Must not benull
.- Returns:
- the instantiated entity. Guaranteed to be not
null
.
-
getPropertyAccessor
<T> PersistentPropertyPathAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance) Return aPersistentPropertyAccessor
to access property values of theinstance
.- Parameters:
persistentEntity
- the kind of entity to operate on. Must not benull
.instance
- the instance to operate on. Must not benull
.- Returns:
- guaranteed to be not
null
.
-
introspectProjection
Introspect the givenresult type
in the context of theentity type
whether the returned type is a projection and what property paths are participating in the projection.- Parameters:
resultType
- the type to project on. Must not be null.entityType
- the source domain type. Must not be null.- Returns:
- the introspection result.
- Since:
- 3.2
- See Also:
-
project
Apply a projection toRowDocument
and return the projection return typeR
.Non-projecting
descriptors fall back toregular object materialization
.- Parameters:
descriptor
- the projection descriptor, must not be null.document
- must not be null.- Returns:
- a new instance of the projection return type
R
. - Since:
- 3.2
-
read
Read aRowDocument
into the requestedaggregate type
.- Type Parameters:
R
- aggregate type.- Parameters:
type
- target aggregate type.source
- sourceRowDocument
.- Returns:
- the converted object.
- Since:
- 3.2
-
readValue
Read a relational value into the desireddestination type
.- Parameters:
value
- a value as it is returned by the driver accessing the persistence store. May benull
.type
-TypeInformation
into which the value is to be converted. Must not benull
.- Returns:
- The converted value. May be
null
.
-
writeValue
Write a property value into a relational type that can be stored natively.- Parameters:
value
- a value as it is used in the object model. May benull
.type
-TypeInformation
into which the value is to be converted. Must not benull
.- Returns:
- The converted value. May be
null
.
-
read(java.lang.Class<R>, org.springframework.data.relational.domain.RowDocument)
method instead.