Class MappingRedisConverter
java.lang.Object
org.springframework.data.redis.core.convert.MappingRedisConverter
- All Implemented Interfaces:
InitializingBean, EntityConverter<RedisPersistentEntity<?>, RedisPersistentProperty, Object, RedisData>, EntityReader<Object, RedisData>, EntityWriter<Object, RedisData>, RedisConverter
RedisConverter implementation creating flat binary map structure out of a given domain type. Considers
Indexed annotation for enabling helper structures for finder operations. NOTE
MappingRedisConverter is an InitializingBean and requires
afterPropertiesSet() to be called.
@RedisHash("persons")
class Person {
@Id String id;
String firstname;
List<String> nicknames;
List<Person> coworkers;
Address address;
@Reference Country nationality;
}
The above is represented as:
_class=org.example.Person
id=1
firstname=rand
lastname=al'thor
coworkers.[0].firstname=mat
coworkers.[0].nicknames.[0]=prince of the ravens
coworkers.[1].firstname=perrin
coworkers.[1].address.city=two rivers
nationality=nationality:andora
- Since:
- 1.7
- Author:
- Christoph Strobl, Greg Turnquist, Mark Paluch, Golam Mazid Sajib, Leehyoungwoo
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classValue object representing a binary Redis Hash/Object identifier composed from keyspace and object id in the form of keyspace:id.static classValue object representing a Redis Hash/Object identifier composed from keyspace and object id in the form of keyspace:id. -
Constructor Summary
ConstructorsConstructorDescriptionMappingRedisConverter(@Nullable RedisMappingContext mappingContext, @Nullable IndexResolver indexResolver, @Nullable ReferenceResolver referenceResolver) Creates newMappingRedisConverterand defaultsRedisMappingContextwhen null.MappingRedisConverter(@Nullable RedisMappingContext mappingContext, @Nullable IndexResolver indexResolver, @Nullable ReferenceResolver referenceResolver, @Nullable RedisTypeMapper typeMapper) Creates newMappingRedisConverterand defaultsRedisMappingContextwhen null.MappingRedisConverter(RedisMappingContext context) Creates newMappingRedisConverter. -
Method Summary
Modifier and TypeMethodDescriptionvoid<T> @Nullable TConvert given binary representation to desired target type using the underlyingConversionService.@Nullable IndexResolver<R> Rprotected @Nullable ObjectreadProperty(String path, RedisData source, RedisPersistentProperty persistentProperty) voidsetCustomConversions(@Nullable CustomConversions customConversions) SetCustomConversionsto be applied.voidsetIndexResolver(IndexResolver indexResolver) voidsetReferenceResolver(ReferenceResolver referenceResolver) byte @Nullable []Convert given source to binary representation using the underlyingConversionService.voidprotected voidwritePartialUpdate(PartialUpdate<?> update, RedisData sink)
-
Constructor Details
-
MappingRedisConverter
Creates newMappingRedisConverter.- Parameters:
context- can be null.- Since:
- 2.4
-
MappingRedisConverter
public MappingRedisConverter(@Nullable RedisMappingContext mappingContext, @Nullable IndexResolver indexResolver, @Nullable ReferenceResolver referenceResolver) Creates newMappingRedisConverterand defaultsRedisMappingContextwhen null.- Parameters:
mappingContext- can be null.indexResolver- can be null.referenceResolver- can be not be null.
-
MappingRedisConverter
public MappingRedisConverter(@Nullable RedisMappingContext mappingContext, @Nullable IndexResolver indexResolver, @Nullable ReferenceResolver referenceResolver, @Nullable RedisTypeMapper typeMapper) Creates newMappingRedisConverterand defaultsRedisMappingContextwhen null.- Parameters:
mappingContext- can be null.indexResolver- can be null.referenceResolver- can be null.typeMapper- can be null.- Since:
- 2.1
-
-
Method Details
-
read
-
readProperty
protected @Nullable Object readProperty(String path, RedisData source, RedisPersistentProperty persistentProperty) -
write
-
writePartialUpdate
-
toBytes
Convert given source to binary representation using the underlyingConversionService.- Parameters:
source-- Returns:
- Throws:
ConverterNotFoundException
-
fromBytes
Convert given binary representation to desired target type using the underlyingConversionService.- Parameters:
source-type-- Returns:
- Throws:
ConverterNotFoundException
-
setIndexResolver
-
setReferenceResolver
-
setCustomConversions
SetCustomConversionsto be applied.- Parameters:
customConversions-
-
getMappingContext
- Specified by:
getMappingContextin interfaceEntityConverter<RedisPersistentEntity<?>, RedisPersistentProperty, Object, RedisData>- Specified by:
getMappingContextin interfaceRedisConverter
-
getIndexResolver
- Specified by:
getIndexResolverin interfaceRedisConverter- Returns:
- the configured
IndexResolver, may be null.
-
getEntityInstantiators
- Specified by:
getEntityInstantiatorsin interfaceRedisConverter- Returns:
- the configured
EntityInstantiators.
-
getConversionService
- Specified by:
getConversionServicein interfaceEntityConverter<RedisPersistentEntity<?>, RedisPersistentProperty, Object, RedisData>
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-