title: How to Serialize to Java Object in Spring Data Redis
body: <p>This is my redis Template that i have defined in my @configuration class, it's taking a jedis Connection factory, i have set my custom class Student as the value in RedisTemplate</p>
  <pre><code>    @Bean
      public RedisTemplate&lt;String, Student&gt; template() {
          RedisTemplate&lt;String, Student&gt; template = new RedisTemplate&lt;String, Student&gt;();
          template.setConnectionFactory(connectionFactory());
          template.setKeySerializer(new StringRedisSerializer());
          template.setHashKeySerializer(new StringRedisSerializer());
          template.setHashKeySerializer(new JdkSerializationRedisSerializer());
          template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
          template.setEnableTransactionSupport(true);
          template.afterPropertiesSet();
          return template;
      }
  </code></pre>
  <p>This Is My Student Class</p>
  <pre><code>@Entity
  @Table(name = &quot;student&quot;)
  @Getter
  @Setter
  public class Student implements Serializable {
      
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;id&quot;, nullable = false, unique = true)
      private Integer id;
      
      @Column(name = &quot;full_name&quot;, nullable = false)
      private String fullName;
      
      @Column(name = &quot;email&quot;, nullable = false, unique = true)
      private String email;
      
      @Column(name = &quot;created_on&quot;, nullable = false)
      private LocalDateTime createdOn;
      
      @Column(name = &quot;updated_on&quot;, nullable = false)
      private LocalDateTime updatedOn;
      
      @PrePersist
      public void onCreate() {
          this.createdOn = LocalDateTime.now();
          this.updatedOn = LocalDateTime.now();
      }
      
      @PreUpdate
      public void onUpdate() {
          this.updatedOn = LocalDateTime.now();
      }
  }
  </code></pre>
  <p>Here is My Controller code</p>
  <pre><code>    @GetMapping(&quot;/student/{id}&quot;)
      @Cacheable(key=&quot;#id&quot;, value = &quot;student&quot;)
      public Student getStudentHandler(@PathVariable Integer id) {
          return studentService.getStudentById(id);
      }
  </code></pre>
  <p>I am seeing data in this form using redis-cli</p>
  <pre><code>127.0.0.1:6380&gt; get student::1
  &quot;\xac\xed\x00\x05sr\x00 com.demo.school.entity.Student\xc7\x8f\xd4\xd3\x86S@\x9c\x02\x00\x05L\x00\tcreatedOnt\x00\x19Ljava/time/LocalDateTime;L\x00\x05emailt\x00\x12Ljava/lang/String;L\x00\bfullNameq\x00~\x00\x02L\x00\x02idt\x00\x13Ljava/lang/Integer;L\x00\tupdatedOnq\x00~\x00\x01xpsr\x00\rjava.time.Ser\x95]\x84\xba\x1b\&quot;H\xb2\x0c\x00\x00xpw\x0e\x05\x00\x00\a\xe4\x0c\x1c\x0f!*\x1ejA@xt\x00\rabc@gmail.comt\x00\x03abcsr\x00\x11java.lang.Integer\x12\xe2\xa0\xa4\xf7\x81\x878\x02\x00\x01I\x00\x05valuexr\x00\x10java.lang.Number\x86\xac\x95\x1d\x0b\x94\xe0\x8b\x02\x00\x00xp\x00\x00\x00\x01sq\x00~\x00\x05w\x0e\x05\x00\x00\a\xe4\x0c\x1c\x0f!*\x1ej\x93Hx&quot;
  
  </code></pre>
  <p>I am Using Postgresql as my database and redis for caching
  How Can i make this readable.</p>