Class BasicRelationalConverter
java.lang.Object
org.springframework.data.relational.core.conversion.BasicRelationalConverter
- All Implemented Interfaces:
RelationalConverter
RelationalConverter that uses a MappingContext to apply basic conversion of relational values to
property values.
Conversion is configurable by providing a customized CustomConversions.
- Author:
- Mark Paluch, Jens Schauder, Chirag Tailor, Vincent Galloy
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context) Creates a newBasicRelationalConvertergivenMappingContext.BasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, CustomConversions conversions) -
Method Summary
Modifier and TypeMethodDescription<T> TcreateInstance(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) Create a new instance ofPersistentEntitygivenParameterValueProviderto obtain constructor properties.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.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.
-
Constructor Details
-
BasicRelationalConverter
public BasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context) Creates a newBasicRelationalConvertergivenMappingContext.- Parameters:
context- must not be null.
-
BasicRelationalConverter
public BasicRelationalConverter(MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> context, CustomConversions conversions) - Parameters:
context- must not be null.conversions- must not be null.
-
-
Method Details
-
getConversionService
Description copied from interface:RelationalConverterReturns the underlyingConversionServiceused by the converter.- Specified by:
getConversionServicein interfaceRelationalConverter- Returns:
- never null.
-
getConversions
-
getMappingContext
public MappingContext<? extends RelationalPersistentEntity<?>,? extends RelationalPersistentProperty> getMappingContext()Description copied from interface:RelationalConverterReturns the underlyingMappingContextused by the converter.- Specified by:
getMappingContextin interfaceRelationalConverter- Returns:
- never null
-
getPropertyAccessor
public <T> PersistentPropertyPathAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance) Description copied from interface:RelationalConverterReturn aPersistentPropertyAccessorto access property values of theinstance.- Specified by:
getPropertyAccessorin interfaceRelationalConverter- 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.
-
createInstance
public <T> T createInstance(PersistentEntity<T, RelationalPersistentProperty> entity, Function<Parameter<?, RelationalPersistentProperty>, Object> parameterValueProvider) Description copied from interface:RelationalConverterCreate a new instance ofPersistentEntitygivenParameterValueProviderto obtain constructor properties.- Specified by:
createInstancein interfaceRelationalConverter- 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.
-
readValue
Description copied from interface:RelationalConverterRead a relational value into the desireddestination type.- Specified by:
readValuein interfaceRelationalConverter- 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
Description copied from interface:RelationalConverterWrite a property value into a relational type that can be stored natively.- Specified by:
writeValuein interfaceRelationalConverter- 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.
-
getEntityInstantiators
Description copied from interface:RelationalConverterReturn the underlyingEntityInstantiators.- Specified by:
getEntityInstantiatorsin interfaceRelationalConverter- Returns:
-