title: spring-data-redis Jackson serialization
body: <p>I'm attempting to use the Jackson serialization feature of spring-data-redis. I am building a ObjectMapper and using the GenericJackson2JsonRedisSerializer as the serializer for the redisTemplate: </p>
  
  <pre><code>
  
      @Configuration
      public class SampleModule {
          @Bean
          public ObjectMapper objectMapper() {
              return Jackson2ObjectMapperBuilder.json()
                      .serializationInclusion(JsonInclude.Include.NON_NULL) // Don’t include null values
                      .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) //ISODate
                      .build();
          }
  
          @Bean
          public RedisTemplate getRedisTemplate(ObjectMapper objectMapper, RedisConnectionFactory redisConnectionFactory){
              RedisTemplate redisTemplate = new RedisTemplate();
              redisTemplate.setDefaultSerializer(new GenericJackson2JsonRedisSerializer(objectMapper));
              redisTemplate.setConnectionFactory(redisConnectionFactory);
              return redisTemplate;
          }
      }
  
  </code></pre>
  
  <p>I have a SampleBean I am attempting to save: </p>
  
  <pre><code>
  
      @RedisHash("sampleBean")
      public class SampleBean {
          @Id
          String id;
          String value;
          Date date;
  
          public SampleBean(String value, Date date) {
              this.value = value;
              this.date = date;
          }
      } 
  
  </code></pre>
  
  <p>And a repository for that bean:</p>
  
  <pre><code>
  
      public interface SampleBeanRepository extends CrudRepository {
      }
  
  </code></pre>
  
  <p>I am then trying to write the bean to Redis:</p>
  
  <pre><code>
  
      ConfigurableApplicationContext context =    SpringApplication.run(SampleRedisApplication.class, args);
  
      SampleBean helloSampleBean = new SampleBean("hello", new Date());
      ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
      logger.info("Expecting date to be written as: " + objectMapper.writeValueAsString(helloSampleBean.date));
  
      SampleBeanRepository repository = context.getBean(SampleBeanRepository.class);
      repository.save(helloSampleBean);
  
      context.close();
  
  </code></pre>
  
  <p>I expect the redisTemplate to use the Serializer to write the Date inside of the SampleBean as a Timestamp, however it is written as a long.</p>
  
  <p>The relevant spring-data-redis reference: <a href="http://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis:serializer" rel="nofollow noreferrer">http://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis:serializer</a>
  Full code sample: <a href="https://github.com/bandyguy/spring-redis-jackson-sample-broken" rel="nofollow noreferrer">https://github.com/bandyguy/spring-redis-jackson-sample-broken</a></p>