Module spring.data.relational
Interface RelationalConverter
- All Known Implementing Classes:
AbstractRelationalConverter,BasicRelationalConverter,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> TcreateInstance(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) Deprecated.Returns the underlyingConversionServiceused by the converter.Return the underlyingEntityInstantiators.MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> Returns the underlyingMappingContextused by the converter.getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance) Return aPersistentPropertyAccessorto access property values of theinstance.<M,D> EntityProjection<M, D> introspectProjection(Class<M> resultType, Class<D> entityType) Introspect the givenresult typein the context of theentity typewhether the returned type is a projection and what property paths are participating in the projection.<R> Rproject(EntityProjection<R, ?> descriptor, RowDocument document) Apply a projection toRowDocumentand return the projection return typeR.<R> Rread(Class<R> type, RowDocument source) Read aRowDocumentinto 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 underlyingConversionServiceused by the converter.- Returns:
- never null.
-
getEntityInstantiators
EntityInstantiators getEntityInstantiators()Return the underlyingEntityInstantiators.- Since:
- 2.3
-
getMappingContext
MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> getMappingContext()Returns the underlyingMappingContextused 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 ofPersistentEntitygivenParameterValueProviderto 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 aPersistentPropertyAccessorto 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 typein the context of theentity typewhether 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 toRowDocumentand return the projection return typeR.Non-projectingdescriptors 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 aRowDocumentinto 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-TypeInformationinto 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-TypeInformationinto 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.