title: UncategorizedKeyValueException trying to save RedisHash via repository with transaction support
body: <p><strong>Problem:</strong></p>
  
  <p>After enabling transaction support (<code>redisTemplate.setEnableTransactionSupport(true)</code>)
  I get <code>UncategorizedKeyValueException</code> trying to save <code>@RedisHash</code> in repository.</p>
  
  <p>Everything works fine when transaction support is disabled.</p>
  
  <p>Direct operations via <code>RedisTemplate</code> work fine with transaction support.</p>
  
  <p><strong>Stacktrace:</strong></p>
  
  <pre><code>...
  at org.lorem.LoremController.create(TestController.java:41)
  at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
  at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
  at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
  at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
  at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
  at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
  at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
  at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
  ... 17 more
  Caused by: java.lang.NullPointerException
  at org.springframework.data.redis.core.RedisKeyValueAdapter.lambda$put$0(RedisKeyValueAdapter.java:236)
  at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)
  at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
  at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:171)
  at org.springframework.data.redis.core.RedisKeyValueAdapter.put(RedisKeyValueAdapter.java:231)
  at org.springframework.data.keyvalue.core.KeyValueTemplate.lambda$insert$0(KeyValueTemplate.java:165)
  at org.springframework.data.keyvalue.core.KeyValueTemplate.execute(KeyValueTemplate.java:343)
  ... 56 more
  </code></pre>
  
  <p><strong>Background:</strong></p>
  
  <p>I'm using <code>spring-boot-starter-data-redis:2.0.4.RELEASE</code> </p>
  
  <p>Configuration:</p>
  
  <pre><code>@Bean
  @Primary
  StringRedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
      StringRedisTemplate redisTemplate = new StringRedisTemplate();
      redisTemplate.setConnectionFactory(redisConnectionFactory);
      redisTemplate.setEnableTransactionSupport(true);
      redisTemplate.afterPropertiesSet();
  
      return redisTemplate;
  }
  </code></pre>
  
  <p>RedisHash:</p>
  
  <pre><code>@RedisHash("test")
  public class Test {
      private String id;
      private String field;
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public String getField() {
          return field;
      }
  
      public void setField(String field) {
          this.field = field;
      }
  }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>public interface TestRepository extends CrudRepository&lt;Test, String&gt; {
  }
  </code></pre>
  
  <p>Thanks :)</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Things break at the following line in <code>RedisKeyValueAdapter</code>:</p>
  
  <pre><code>boolean isNew = connection.del(objectKey) == 0;
  </code></pre>
  
  <p><code>del()</code> returns null since it runs in a transaction. Doesn't repositories suppose to work with transaction support enabled?</p>