Class MappingRedisConverter

java.lang.Object
org.springframework.data.redis.core.convert.MappingRedisConverter
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.data.convert.EntityConverter<RedisPersistentEntity<?>,RedisPersistentProperty,Object,RedisData>, org.springframework.data.convert.EntityReader<Object,RedisData>, org.springframework.data.convert.EntityWriter<Object,RedisData>, RedisConverter

public class MappingRedisConverter extends Object implements RedisConverter, org.springframework.beans.factory.InitializingBean
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
  • Constructor Details

  • Method Details

    • read

      public <R> R read(Class<R> type, RedisData source)
      Specified by:
      read in interface org.springframework.data.convert.EntityReader<Object,RedisData>
    • readProperty

      @Nullable protected Object readProperty(String path, RedisData source, RedisPersistentProperty persistentProperty)
    • write

      public void write(Object source, RedisData sink)
      Specified by:
      write in interface org.springframework.data.convert.EntityWriter<Object,RedisData>
    • writePartialUpdate

      protected void writePartialUpdate(PartialUpdate<?> update, RedisData sink)
    • toBytes

      public byte[] toBytes(Object source)
      Convert given source to binary representation using the underlying ConversionService.
      Parameters:
      source -
      Returns:
      Throws:
      org.springframework.core.convert.ConverterNotFoundException
    • fromBytes

      public <T> T fromBytes(byte[] source, Class<T> type)
      Convert given binary representation to desired target type using the underlying ConversionService.
      Parameters:
      source -
      type -
      Returns:
      Throws:
      org.springframework.core.convert.ConverterNotFoundException
    • setIndexResolver

      public void setIndexResolver(IndexResolver indexResolver)
    • setReferenceResolver

      public void setReferenceResolver(ReferenceResolver referenceResolver)
    • setCustomConversions

      public void setCustomConversions(@Nullable org.springframework.data.convert.CustomConversions customConversions)
      Set CustomConversions to be applied.
      Parameters:
      customConversions -
    • getMappingContext

      public RedisMappingContext getMappingContext()
      Specified by:
      getMappingContext in interface org.springframework.data.convert.EntityConverter<RedisPersistentEntity<?>,RedisPersistentProperty,Object,RedisData>
      Specified by:
      getMappingContext in interface RedisConverter
    • getIndexResolver

      @Nullable public IndexResolver getIndexResolver()
      Specified by:
      getIndexResolver in interface RedisConverter
      Returns:
      the configured IndexResolver, may be null.
    • getConversionService

      public org.springframework.core.convert.ConversionService getConversionService()
      Specified by:
      getConversionService in interface org.springframework.data.convert.EntityConverter<RedisPersistentEntity<?>,RedisPersistentProperty,Object,RedisData>
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean