title: Spring RedisTemplate : Serialise multiple Model classes into JSON.Need to use Multiple RedisTemplates?
body: <p>I am using Spring Redis support to save my objects in Redis.</p>
  
  <p>I have several DAOs which handle different Model classes:</p>
  
  <p>For example, <code>ShopperHistoryDao</code> save/retrieve objects of <code>ShopperHistoryModel</code>, <code>ShopperItemHistoryDao</code> save/retrieve objects of <code>ItemHistoryModel</code>.</p>
  
  <p>I want to use <code>JacksonJsonRedisSerializer</code> to serialise/deserialize my objects to/from json.</p>
  
  <p>But in the constructor of JacksonJsonRedisSerializer, it takes one specific Model class.</p>
  
  <pre><code>JacksonJsonRedisSerializer(Class&lt;T&gt; type)
  </code></pre>
  
  <p>Does that mean, I have to configure separate <code>RedisTemplates</code> for each different Model class and use them in appropriate DAO implementation?</p>
  
  <p>Something like:</p>
  
  <pre><code>&lt;bean id="redisTemplateForShopperHistoryModel" class="org.springframework.data.redis.core.RedisTemplate"&gt;
      &lt;property name="connectionFactory" ref="jedisConnectionFactory" /&gt;
      &lt;property name="valueSerializer"&gt;
          &lt;bean id="redisJsonSerializer" 
                          class="org.springframework.data.redis.serializer.JacksonJsonRedisSerializer"&gt;
              &lt;constructor-arg type="java.lang.Class" value="ShopperHistoryModel.class"/&gt;
          &lt;/bean&gt;   
      &lt;/property&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="redisTemplateForItemHistoryModel" class="org.springframework.data.redis.core.RedisTemplate"&gt;
      &lt;property name="connectionFactory" ref="jedisConnectionFactory" /&gt;
      &lt;property name="valueSerializer"&gt;
          &lt;bean id="redisJsonSerializer" 
                          class="org.springframework.data.redis.serializer.JacksonJsonRedisSerializer"&gt;
              &lt;constructor-arg type="java.lang.Class" value="ItemHistoryModel.class"/&gt;
          &lt;/bean&gt;   
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>