title: Spring Data JPA Redis : Cannot write custom method based query
body: <p>I have configured Spring Data JPA with Redis and using <code>RedisRepositories</code> with provides methods like <code>find()</code>, <code>findAll()</code> etc. All these methods seem to be working just fine, but I am not able to write my custom method like.</p>
  
  <blockquote>
    <p>RedisEntity findByGenderAndGrade(String gender, String grade);</p>
  </blockquote>
  
  <p>RedisEntity is a simple POJO Entity class. If you want any more info, please let me know in messages.</p>
  
  <p>Following is my entity:</p>
  
  <pre><code>@Data
  @RedisHash("test1")
  public class RedisEntity implements Serializable {
  
      @Id
      @GeneratedValue
      private String id;
      private String name;
      private String gender;
      private Integer grade;
  }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>@Repository
  public interface TestRepository extends JpaRepository&lt;RedisEntity, String&gt; {
  
      List&lt;RedisEntity&gt; findAllByGender(String gender);
      List&lt;RedisEntity&gt; findAllByGrade(Integer grade);
  }
  </code></pre>
  
  <p>Service/Controller:</p>
  
  <pre><code>        @Override
          public List&lt;RedisEntity&gt; getById(String id) {
              return testRepository.findById(id); //returns data perfectly.
          }
          @Override
          public List&lt;RedisEntity&gt; getAllByGender(String gender) {
              return testRepository.findAllByGender(gender); //returns [] 
          }
  
          @Override
          public void saveEntity(RedisEntity redisEntity) {
              testRepository.save(redisEntity); // saves it in redis perfectly.
          }
  </code></pre>
  
  <p>Also,
  findByGender and findAllByGender both give [], although I can see data in my redis database and save it as well.</p>
  
  <p>As requested by FrançoisDupire,</p>
  
  <pre><code>@Configuration
  public class RedisConfig {
  
      @Autowired
      private DeploymentProperties deploymentProperties;
  
      private static Logger logger = LoggerFactory.getLogger(RedisConfig.class);
  
      @Bean
      JedisConnectionFactory jedisConnectionFactory() {
          RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration("localhost", 6379);
          redisStandaloneConfiguration.setPassword(RedisPassword.of("root"));
          return new JedisConnectionFactory(redisStandaloneConfiguration);
      }
  
      @Bean
      public RedisTemplate&lt;String, Object&gt; redisTemplate() {
          RedisTemplate&lt;String, Object&gt; template = new RedisTemplate&lt;&gt;();
          template.setConnectionFactory(jedisConnectionFactory());
          return template;
      }
  }
  </code></pre>
  
  <p>Also, I had referred this article: <a href="http://www.baeldung.com/spring-data-redis-tutorial" rel="nofollow noreferrer">Baeldung article on Spring data redis</a></p>